Skip to content

Instantly share code, notes, and snippets.

@qingfeng
Created May 20, 2009 12:11
Show Gist options
  • Select an option

  • Save qingfeng/114776 to your computer and use it in GitHub Desktop.

Select an option

Save qingfeng/114776 to your computer and use it in GitHub Desktop.
#
# controller.py
# sha1_pyobjc
#
# Created by yanxu on 09/05/18.
# Copyright (c) 2009 SINA. All rights reserved.
#
from objc import YES, NO, IBAction, IBOutlet
from Foundation import *
from AppKit import *
from hashlib import sha1
class controller(NSObject):
text = IBOutlet("text")
result = IBOutlet("result")
# objc-style init, must return self
def init(self):
self = super(controller, self).init()
return self
def applicationDidFinishLaunching_(self, sender):
NSLog("Start......")
@IBAction
def convert_(self,sender):
v = self.text.stringValue()
self.result.setStringValue_( sha1(v.encode("utf8")).hexdigest() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment