Updates
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import numberfy from "./numberfy";
|
||||
|
||||
export type GrabEncryptionKeysParam = {
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
apiKey?: string;
|
||||
algorithm?: string;
|
||||
bufferAllocSize?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* # Grab Encryption Keys
|
||||
* @description Grab Required Encryption Keys
|
||||
*/
|
||||
export default function grabKeys(param?: GrabEncryptionKeysParam) {
|
||||
return {
|
||||
key: param?.encryptionKey || process.env.DSQL_ENCRYPTION_PASSWORD,
|
||||
keyLen: process.env.DSQL_ENCRYPTION_KEY_LENGTH
|
||||
? Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH)
|
||||
: 24,
|
||||
salt: param?.encryptionSalt || process.env.DSQL_ENCRYPTION_SALT,
|
||||
apiKey: param?.apiKey || process.env.DSQL_API_KEY,
|
||||
algorithm:
|
||||
param?.algorithm ||
|
||||
process.env.DSQL_ENCRYPTION_ALGORITHM ||
|
||||
"aes-192-cbc",
|
||||
bufferAllocSize:
|
||||
param?.bufferAllocSize ||
|
||||
(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE
|
||||
? numberfy(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE)
|
||||
: undefined) ||
|
||||
16,
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
* numberfy("123.456", 0) // 123
|
||||
* numberfy("123.456", 3) // 123.456
|
||||
*/
|
||||
export default function numberfy(num: any, decimals: number): number {
|
||||
export default function numberfy(num: any, decimals?: number): number {
|
||||
try {
|
||||
const numberfiedNum = Number(num);
|
||||
if (typeof numberfiedNum !== "number") return 0;
|
||||
|
||||
Reference in New Issue
Block a user