mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Fix Affine-Cipher encrypt and drypt func (#1077)
This commit is contained in:
@@ -6,6 +6,8 @@ describe('Test Affine Cipher', () => {
|
||||
expect(() => encrypt('null', null, null)).toThrow()
|
||||
expect(() => encrypt('null', 1, null)).toThrow()
|
||||
expect(() => encrypt('null', null, 1)).toThrow()
|
||||
expect(() => encrypt('null', 2, 1)).toThrow()
|
||||
expect(() => encrypt('null', 4, 1)).toThrow()
|
||||
})
|
||||
|
||||
it('Test - 2, Pass invalid input to decrypt function', () => {
|
||||
@@ -13,14 +15,14 @@ describe('Test Affine Cipher', () => {
|
||||
expect(() => decrypt('null', null, null)).toThrow()
|
||||
expect(() => decrypt('null', 1, null)).toThrow()
|
||||
expect(() => decrypt('null', null, 1)).toThrow()
|
||||
expect(() => encrypt('null', 2, 1)).toThrow()
|
||||
expect(() => encrypt('null', 4, 1)).toThrow()
|
||||
})
|
||||
|
||||
it('Test - 3 Pass string value to encrypt and ecrypt function', () => {
|
||||
const a = 5
|
||||
const b = 8
|
||||
expect(decrypt(encrypt('HELLO WORLD', a, b), a, b)).toBe('HELLO WORLD')
|
||||
expect(decrypt(encrypt('ABC DEF', a, b), a, b)).toBe('ABC DEF')
|
||||
expect(decrypt(encrypt('Brown fox jump over the fence', a, b), a, b)).toBe(
|
||||
expect(decrypt(encrypt('HELLO WORLD', 5, 8), 5, 8)).toBe('HELLO WORLD')
|
||||
expect(decrypt(encrypt('ABC DEF', 3, 5), 3, 5)).toBe('ABC DEF')
|
||||
expect(decrypt(encrypt('Brown fox jump over the fence', 7, 3), 7, 3)).toBe(
|
||||
'BROWN FOX JUMP OVER THE FENCE'
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user