| 52 | |
| 53 | // Define a singleton class for Base64 encryption |
| 54 | class Base64Encryption implements Encryption { |
| 55 | private static instance: Base64Encryption; |
| 56 | |
| 57 | private constructor() {} |
| 58 | |
| 59 | // Get the singleton instance |
| 60 | // 获取单例实例 |
| 61 | public static getInstance(): Base64Encryption { |
| 62 | if (!Base64Encryption.instance) { |
| 63 | Base64Encryption.instance = new Base64Encryption(); |
| 64 | } |
| 65 | return Base64Encryption.instance; |
| 66 | } |
| 67 | |
| 68 | encrypt(plainText: string) { |
| 69 | return UTF8.parse(plainText).toString(Base64); |
| 70 | } |
| 71 | |
| 72 | decrypt(cipherText: string) { |
| 73 | return Base64.parse(cipherText).toString(UTF8); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // Define a singleton class for MD5 Hashing |
| 78 | class MD5Hashing implements Hashing { |
nothing calls this directly
no outgoing calls
no test coverage detected