-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
/** | ||
* Encodes a payload to base64. | ||
* | ||
* @param payload - The data to be encoded. | ||
* @returns The base64-encoded payload. | ||
* | ||
* @example | ||
* const data = 'Hello, world!'; | ||
* const encodedData = encodeBase64(data); | ||
* console.log(encodedData); // Base64-encoded data | ||
*/ | ||
export declare const encodeBase64: (payload: string) => string; | ||
/** | ||
* Decodes a base64-encoded payload to a string. | ||
* | ||
* @param payload - The base64-encoded data to be decoded. | ||
* @returns The decoded payload as a UTF-8 string. | ||
* | ||
* @example | ||
* const encodedData = 'SGVsbG8sIHdvcmxkIQ=='; // Base64-encoded data | ||
* const decodedData = decodeBase64(encodedData); | ||
* console.log(decodedData); // Decoded data: "Hello, world!" | ||
*/ | ||
export declare const decodeBase64: (payload: string) => string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export declare const encrypt: (data: string, iv: string, password: string, salt: string) => string; | ||
export declare const decrypt: (data: string, iv: string, password: string, salt: string) => string; | ||
export declare const generateIv: () => string; | ||
export declare const algorithm = "aes-256-cbc"; | ||
export declare const inputEncoding = "utf8"; | ||
export declare const outputEncoding = "base64"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @module crypto | ||
* @preferred | ||
*/ | ||
/** | ||
* Decrypts data using the given parameters. | ||
* | ||
* @param encryptedData - The encrypted data. | ||
* @param iv - The initialization vector. | ||
* @param password - The password for decryption. | ||
* @param salt - The salt for key derivation. | ||
* @returns The decrypted data. | ||
* | ||
* @example | ||
* const encrypted = 'EncryptedDataHere'; // Encrypted data obtained from the encryption process | ||
* const iv = '1234567890123456'; // Initialization vector used in the encryption process | ||
* const password = 'MySecretPassword'; // Password used in the encryption process | ||
* const salt = 'MySalt'; // Salt used in the encryption process | ||
* const decrypted = decrypt(encrypted, iv, password, salt); | ||
* console.log(decrypted); | ||
*/ | ||
export declare const decrypt: (encryptedData: string, iv: string, password: string, salt: string) => string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @module crypto | ||
* @preferred | ||
*/ | ||
/** | ||
* Encrypts data using the given parameters. | ||
* | ||
* @param data - The data to be encrypted. | ||
* @param iv - The initialization vector. | ||
* @param password - The password for encryption. | ||
* @param salt - The salt for key derivation. | ||
* @returns The encrypted data. | ||
* | ||
* @example | ||
* const data = 'Sensitive information'; | ||
* const iv = '1234567890123456'; // 16 characters | ||
* const password = 'MySecretPassword'; | ||
* const salt = 'MySalt'; | ||
* const encrypted = encrypt(data, iv, password, salt); | ||
* console.log(encrypted); | ||
*/ | ||
export declare const encrypt: (data: string, iv: string, password: string, salt: string) => string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
/** | ||
* Generates a random salt for key derivation. | ||
* | ||
* @param bytes - The number of bytes for the generated salt. Default is 16 bytes. | ||
* @returns The generated salt as a hexadecimal string. | ||
* | ||
* @example | ||
* const salt = generateRandomSalt(); | ||
* console.log(salt); // Random hexadecimal salt | ||
*/ | ||
export declare function generateRandomSalt(bytes?: number): string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Generates a random initialization vector (IV) for encryption. | ||
* | ||
* @returns The generated initialization vector as a base64-encoded string. | ||
* | ||
* @example | ||
* const iv = generateIv(); | ||
* console.log(iv); // Random base64-encoded initialization vector | ||
*/ | ||
export declare const generateIv: () => string; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export * from './base64'; | ||
export * from './crypto'; | ||
export * from './placeholder'; | ||
export * from './genRandomSalt'; | ||
export * from './generateIv'; | ||
export * from './encrypt'; | ||
export * from './decrypt'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.