How to serialize/store the ciphertext encrypted by hybrid CPabe_BSW07 in Charm

前端 未结 2 944
野趣味
野趣味 2021-01-25 02:42

I want to store the ciphertext encrypted by hybrid cpabe_BSW07 in files, but I found errors when pickling the ciphertext:

raise TypeError, \"can\'t pickle %s objects\         


        
2条回答
  •  孤独总比滥情好
    2021-01-25 03:16

    I had the same problem trying to serialize a dict generated by Charm crypto using json, pickle, simplejson and solved it by using charm.core.engine.util.objectToBytes|bytesToObject methods.

    from charm.core.engine.util import objectToBytes, bytesToObject
    <...>
    emsg = objectToBytes(cipher_text,group)
    msg = bytesToObject(fin.read(),group)
    

提交回复
热议问题