![]() The goal is to colorize proper syntax in real time, while removing colorization from improper syntax. This is actually for a RegEx parser that is in the new SecureCRT 7.3 terminal application. Restriction: You cannot use: \s or ' ' (the parser I'm using doesn't allow it) Given the string: Start Fa1/0/1 Gig2/0 Fa1/0/ Ending The problem is that is also matches the Fa1/0 part of Fa1/0/ or Fa1/0a which is incorrect and shouldn't be matched at all. The closest I've been able to get is: *+(?:+)+ Return 0 if DecryptionRoutine(bUseV2, ConfigPassphrase, argv) else -1Įxit(Main(len(sys.argv), sys.argv)) 该脚本需要依赖pycryptodome模块,该模块是一个加解密算法的模块包,该模块是p圜yrpto模块的延续。由于p圜yrpto在python3.I'm need help figuring out a RegEx statement to help me match properly interfaces on a switch/router.Įxample: Correct matches may be: Fa1/0, Gig2/0/2, Fa3/0/33/333, G1/0/0:1, Gi0/0.900 etc. Return 0 if EncryptionRoutine(bUseV2, ConfigPassphrase, argv) else -1 Print('Error: ConfigPassphrase is not supported if "-v2" is not specified') If bUseV2 = False and len(ConfigPassphrase) != 0: Print(SecureCRTCrypto().Decrypt(Ciphertext))Įlif argv.lower() = '-p' and i + 1 < argc - 1: Print(SecureCRTCryptoV2(ConfigPassphrase).Decrypt(Ciphertext)) Print(SecureCRTCrypto().Encrypt(Plaintext))ĭef DecryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Ciphertext : str): Print(SecureCRTCryptoV2(ConfigPassphrase).Encrypt(Plaintext)) Print(' NOTICE: Ciphertext string must be a hex string.')ĭef EncryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Plaintext : str): Print(' Plaintext string or ciphertext string.') Print(' The config passphrase that SecureCRT uses.') Print(' Encrypt/Decrypt with "Password V2" algorithm.') Print(' This parameter must be specified.') ![]() Print(' "enc" for encryption, "dec" for decryption.') If SHA256.new(plain_bytes).digest() != plain_bytes_digest: If len(plain_bytes_digest) != SHA256.digest_size: If len(plain_bytes) != plain_bytes_length: Plain_bytes_length = int.from_bytes(padded_plain_bytes, 'little') Padded_plain_bytes = crypt(omhex(Ciphertext)) ![]() Return cipher.encrypt(padded_plain_bytes).hex() Os.urandom(AES.block_size - len(plain_bytes) % AES.block_size)Ĭipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV) Len(plain_bytes).to_bytes(4, 'little') + \ Raise OverflowError('Plaintext is too long.') Return cipher1.encrypt(os.urandom(4) + cipher2.encrypt(padded_plain_bytes) + os.urandom(4)).hex()ĭecrypt ciphertext and return corresponding plaintext.Ĭiphertext: A hex string that will be decrypted.Ĭiphered_bytes = omhex(Ciphertext) Padded_plain_bytes = plain_bytes + os.urandom(Blowfish.block_size - len(plain_bytes) % Blowfish.block_size)Ĭipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)Ĭipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV) Plain_bytes = Plaintext.encode('utf-16-le') Plaintext: A string that will be encrypted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |