MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / isCorrectFormat

Function isCorrectFormat

Ciphers/AffineCipher.js:39–53  ·  view source on GitHub ↗

* Argument validation * @param {String} str - String to be checked * @param {Number} a - A coefficient to be checked * @param {Number} b - B coefficient to be checked * @return {Boolean} Result of the checking

(str, a, b)

Source from the content-addressed store, hash-verified

37 * @return {Boolean} Result of the checking
38 */
39function isCorrectFormat(str, a, b) {
40 if (typeof a !== 'number' || typeof b !== 'number') {
41 throw new TypeError('Coefficient a, b should be number')
42 }
43
44 if (typeof str !== 'string') {
45 throw new TypeError('Argument str should be String')
46 }
47
48 if (!CoPrimeCheck(a, 26)) {
49 throw new Error(a + ' is not coprime of 26')
50 }
51
52 return true
53}
54
55/**
56 * Find character index based on ASCII order

Callers 2

encryptFunction · 0.85
decryptFunction · 0.85

Calls 1

CoPrimeCheckFunction · 0.90

Tested by

no test coverage detected