Does anybody know what encrypting technique is JDeveloper/SQL Developer using to persist credentials?

后端 未结 11 2156
广开言路
广开言路 2020-12-22 18:46

I\'d be more than interesting for me to understand which technique is being used here to persist sensible data since I\'m needing to implement a similar solution. Here\'s a

11条回答
  •  难免孤独
    2020-12-22 19:25

    Here's a python snippet if anyone is intersted. It's a translation of Adam Paynter's example above. It uses pyDes

    import os
    import pyDes
    
    import binascii
    
    if __name__ == '__main__':
        # Encrypt example
        zero = '\0\0\0\0\0\0\0\0'
        key = os.urandom(8)
        plainText = 'open sesame'
        cipher = pyDes.des(key, mode=pyDes.CBC, IV=zero, padmode=pyDes.PAD_PKCS5)
    
        cipherText = '\5%s%s' % (key, cipher.encrypt(plainText))
        cipherHex = binascii.hexlify(cipherText)
    
        # This is what SQLDeveloper stores in XML
        print cipherHex
    
        # Decrypt above
        cipherText = binascii.unhexlify(cipherHex)
        assert cipherHex[0:2] == '05'
        key = cipherText[1:1+8]
        cipher = pyDes.des(key, mode=pyDes.CBC, IV=zero, padmode=pyDes.PAD_PKCS5)
        print cipher.decrypt(cipherText[1+8:])
    

提交回复
热议问题