Skip to content

Commit

Permalink
rsa
Browse files Browse the repository at this point in the history
  • Loading branch information
RobSinn committed Aug 17, 2014
1 parent bb75be9 commit cb55818
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 1 deletion.
21 changes: 21 additions & 0 deletions ChangeThredds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import rsa
import zoo

def ChangeThredds(conf,inputs,outputs):
crypto = inputs["url"]["value"]

privatefile = open('rsa/privateKey.pem')
keydata = privatefile.read()
privatekey = rsa.PrivateKey.load_pkcs1(keydata)
publicfile = open('rsa/publicKey.pem')
pubdata = publicfile.read()
pubkey = rsa.PublicKey.load_pkcs1(pubdata)

newurl = rsa.decrypt(crypto,privatekey)

ThreddServer = open('ThreddServer','w')
ThreddServer.write(newurl)

outputs["Result"]["value"]=("New Server address is " + newurl)

return zoo.SERVICE_SUCCEEDED
16 changes: 16 additions & 0 deletions ChangeThredds.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import rsa

def ChangeThredds(conf,inputs,outputs):
crypto = inputs["url"]["value"]

privatefile = open('rsa/privateKey.pem')
keydata = privatefile.read()
privatekey = rsa.PrivateKey.load_pkcs1(keydata)
publicfile = open('rsa/publicKey.pem')
pubdata = publicfile.read()
pubkey = rsa.PublicKey.load_pkcs1(pubdata)

newurl = rsa.decrypt(crypto,privatekey)

ThreddServer = open('ThreddServer','w')
ThreddServer.write(newurl)
48 changes: 48 additions & 0 deletions ChangeThredds.zcfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[ChangeThredds]
Title = Set a new Thredds server
Abstract = Set a new Thredds server
processVersion = 2
storeSupported = true
statusSupported = true
serviceProvider = ChangeThredds
serviceType = Python
<MetaData>
title = Demo
</MetaData>
<DataInputs>
[url]
Title = A single url such as http://115.146.84.143:8080
Abstract = Url to the Thredds server
minOccurs = 1
maxOccurs = 1
<MetaData>
title = Meta
</MetaData>
<LiteralData>
DataType = string
<Default>
UOM = meter
</Default>
<Supported>
UOM = meter
</Supported>
</LiteralData>
</DataInputs>
<DataOutputs>
[Result]
Title = Operation Service Provider
Abstract = A Zoo web service that calls various operations on netcdf data.
<MetaData>
title = My test
</MetaData>
<LiteralData>
DataType = string
<Default>
UOM = meter
</Default>
<Supported>
UOM = meter
</Supported>
</LiteralData>
</DataOutputs>

Empty file added ChangeThredds.zcfg~
Empty file.
3 changes: 2 additions & 1 deletion Operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def Operation(conf,inputs,outputs):
urls = getUrls(inputs["urls"]["value"])
filename = outputFileName(inputs["selection"]["value"],urls)
outputFile = "/var/www/cgi-bin/Thredds/outputs/" + filename
serverAddr = "http://115.146.84.143:8080"
serverFile = open('ThreddServer')
serverAddr = serverFile.read().strip()
if len(urls) < 1:
conf["lenv"]["message"] = "There has to be atleast one dataset"
return zoo.SERVICE_FAILED
Expand Down
1 change: 1 addition & 0 deletions ThreddServer
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://115.146.84.143:8080
1 change: 1 addition & 0 deletions rsa/crpto.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
N���0��%����3�f�f}X��~()���2������~�'�*� K�!� ����Z�o!
Expand Down
33 changes: 33 additions & 0 deletions rsa/rsaTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import rsa
import urllib
import base64

def main():
test = "http://115.146.84.143:8080"
privatefile = open('privateKey.pem')
keydata = privatefile.read()
privatekey = rsa.PrivateKey.load_pkcs1(keydata)
publicfile = open('publicKey.pem')
pubdata = publicfile.read()
pubkey = rsa.PublicKey.load_pkcs1(pubdata)

crypto = rsa.encrypt(test,pubkey)
newtest = rsa.decrypt(crypto,privatekey)
print crypto
urlForm = urllib.quote_plus(crypto)
print urlForm
print newtest

print rsa.decrypt(urllib.unquote_plus(urlForm),privatekey)
quickTest = urllib.unquote_plus("%A0%5E%CC_V%17%B9W%E0%D3%93%BF%84%87pqg%07%FA%CC%03%B0%DB%24%99%F7%DCAe%25i%0F-%AC%CA.%B8%2C%E0s%FC%DE%2C%DE%BFF%FA%B0%60%16%D6%92%AE%9DVT%04%83%91%1F%C3%1DI%C0")
print quickTest
print rsa.decrypt(quickTest,privatekey)
print "with utf8"
#code = urllib.quote(crypto).encode("utf8")
#code = HttpContext.Current.Server.UrlEncode(urllib.quote_plus(crypto))
#print rsa.decrypt(urllib.unquote_plus(code),privatekey)
print rsa.decrypt(urllib.unquote_plus(base64.b64decode(base64.b64encode(urllib.quote_plus(crypto)))),privatekey)

print base64.b64encode(crypto)


Binary file added rsa/rsaTest.pyc
Binary file not shown.
33 changes: 33 additions & 0 deletions rsa/rsaTest.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import rsa
import urllib
import base64

def main():
test = "http://115.146.84.143:8080"
privatefile = open('privateKey.pem')
keydata = privatefile.read()
privatekey = rsa.PrivateKey.load_pkcs1(keydata)
publicfile = open('publicKey.pem')
pubdata = publicfile.read()
pubkey = rsa.PublicKey.load_pkcs1(pubdata)

crypto = rsa.encrypt(test,pubkey)
newtest = rsa.decrypt(crypto,privatekey)
print crypto
urlForm = urllib.quote_plus(crypto)
print urlForm
print newtest

print rsa.decrypt(urllib.unquote_plus(urlForm),privatekey)
quickTest = urllib.unquote_plus("%A0%5E%CC_V%17%B9W%E0%D3%93%BF%84%87pqg%07%FA%CC%03%B0%DB%24%99%F7%DCAe%25i%0F-%AC%CA.%B8%2C%E0s%FC%DE%2C%DE%BFF%FA%B0%60%16%D6%92%AE%9DVT%04%83%91%1F%C3%1DI%C0")
print quickTest
print rsa.decrypt(quickTest,privatekey)
print "with utf8"
#code = urllib.quote(crypto).encode("utf8")
#code = HttpContext.Current.Server.UrlEncode(urllib.quote_plus(crypto))
#print rsa.decrypt(urllib.unquote_plus(code),privatekey)
print rsa.decrypt(urllib.unquote_plus(base64.b64decode(base64.b64encode(urllib.quote_plus(crypto)))),privatekey)

print base64.b64encode(urllib.quote_plus(crypto))


15 changes: 15 additions & 0 deletions rsa/sign.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import rsa

def main():
test = "http://115.146.84.143:8080"
privatefile = open('privateKey.pem')
keydata = privatefile.read()
privatekey = rsa.PrivateKey.load_pkcs1(keydata)
publicfile = open('publicKey.pem')
pubdata = publicfile.read()
pubkey = rsa.PublicKey.load_pkcs1(pubdata)

signature = rsa.sign(test, privatekey, 'SHA-1')

print rsa.verify(test, signature, pubkey)
print signature
Binary file added rsa/sign.pyc
Binary file not shown.

0 comments on commit cb55818

Please sign in to comment.