File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 1
- export class Algorithm {
2
- public static readonly AES128CBC = "aes-128-cbc" ;
3
- public static readonly AES256CBC = "aes-256-cbc" ;
1
+ export enum Algorithm {
2
+ AES128CBC = "aes-128-cbc" ,
3
+ AES256CBC = "aes-256-cbc"
4
4
}
Original file line number Diff line number Diff line change 1
1
import { Algorithm } from "./algorithm.const" ;
2
2
import { generateRandom } from "./random.function" ;
3
3
4
- export const getKeyLength = ( algorithm : string ) : { keyLength : number } => {
4
+ export const getKeyLength = ( algorithm : Algorithm ) : { keyLength : number } => {
5
5
switch ( algorithm ) {
6
6
case Algorithm . AES128CBC :
7
7
return ( {
@@ -15,7 +15,7 @@ export const getKeyLength = (algorithm: string): { keyLength: number } => {
15
15
throw new Error ( "Not (yet) supported algorithm: " + algorithm ) ;
16
16
} ;
17
17
18
- export const generateKey = async ( algorithm : string ) : Promise < string > => {
18
+ export const generateKey = async ( algorithm : Algorithm ) : Promise < string > => {
19
19
const keyLength = getKeyLength ( algorithm ) ;
20
20
21
21
const randomKey = await generateRandom ( { byteLength : keyLength . keyLength } ) ;
You can’t perform that action at this time.
0 commit comments