Skip to content

Commit 11f5c48

Browse files
add bytesToMnemonic
1 parent 99d3bdf commit 11f5c48

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export {
113113
uuidToBytes,
114114
bytesToUuid,
115115
mnemonicToBytes,
116+
bytesToMnemonic,
116117
} from './utils';
117118
export * from './types';
118119
export * from './constants';

src/utils/genMnemonic.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ export function genMnemonic(bits: number): string {
2020
export function mnemonicToBytes(mnemonic: string): Uint8Array {
2121
return bip39.mnemonicToEntropy(mnemonic, wordlist);
2222
}
23+
24+
/**
25+
* Converts a Uint8Array to a mnemonic
26+
*
27+
* @param bytes - The bytes to convert
28+
* @returns The mnemonic string
29+
*/
30+
export function bytesToMnemonic(bytes: Uint8Array): string {
31+
return bip39.entropyToMnemonic(bytes, wordlist);
32+
}

0 commit comments

Comments
 (0)