@g.command('stickynoteenc')def stickynoteenc_f(event, rekey=False): """ Launch editable 'sticky note' for the encrypted node """ if not encOK: g.es('no en/decryption - need python-crypto module') return if not __ENCKEY[0] or rekey: sn_getenckey() c = event['c'] p = c.p v = p.v
def focusin(): if v is c.p.v: decoded = sn_decode(v.b) if decoded is None: return if decoded != nf.toPlainText(): # only when needed to avoid scroll jumping nf.setPlainText(decoded) nf.setWindowTitle(p.h) nf.dirty = False
def focusout(): if not nf.dirty: return enc = sn_encode(str(nf.toPlainText())) if v.b != enc: v.b = enc v.setDirty() # Fix #249: Leo and Stickynote plugin do not request to save c.setChanged(True) nf.dirty = False p = c.p if p.v is v: c.selectPosition(c.p) c.redraw()
if rekey: unsecret = sn_decode(v.b) if unsecret is None: return sn_getenckey() secret = sn_encode(unsecret) v.b = secret // this is new - check if it is old note already encrypted if v.b: decoded = sn_decode(v.b) if decoded is None: return else:
// creating new encrypted note decoded = v.b nf = mknote(c,p, focusin=focusin, focusout=focusout) nf.setPlainText(decoded) if rekey: g.es("Key updated, data decoded with new key shown in window")
def sn_encode(s):
s1 = s.encode('utf8')
pad = b' '*(16-len(s1)%16)
txta = get_encoder().encrypt(s1 + pad)
txt = base64.b64encode(txta)
txt = str(txt, 'utf-8')
wrapped = textwrap.wrap(txt, break_long_words=True)
return '\n'.join(wrapped)
def get_encoder(): key = __ENCKEY[0] if hasattr(AES, 'MODE_EAX'): return AES.new(key, AES.MODE_EAX) else: return AES.new(key)
# txt = get_encoder().encrypt(s1 + pad)
# or
# decoded = get_encoder().decrypt(s1)Does anybody else notices similar behavior? I am using Google Chrome, regularly updated.
Does anybody else notices similar behavior? I am using Google Chrome, regularly updated.I'm not seeing this with up to date Firefox on Windows right now, but I have run into formatting wierdness in g-groups before. One thing that helped was turning off the browser automatic spell checking.