--- /dev/null
+<?php
+# Debian-Depends: php-soap # pour SOAP
+# Debian-Depends: php[45]-curl # pour HTTPS
+include_once("SOAP/Client.php");
+$params = Array("username"=>'test', "password"=>'toto');
+$soapclient = new SOAP_Client("https://example.org/soap");
+$ret = $soapclient->call('crypt6', $params);
+if (PEAR::isError($ret))
+ print("Error: " . $ret->getMessage() . "\n");
+else
+ print("Ok: " . $ret . "\n");
+?>
--- /dev/null
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Debian-Depends: python-soaplib
+# Debian-Suggests: python-wsgiref
+from soaplib.wsgi_soap import SimpleWSGISoapApp
+from soaplib.service import soapmethod
+from soaplib.serializers.primitive import String, Integer, Array
+from random import choice
+from crypt import crypt
+
+class CryptService(SimpleWSGISoapApp):
+
+ def make_salt(self, count=16):
+ choices = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./'
+ return ''.join([choice(choices) for x in range(count)])
+
+ def crypt(self, username, password, method):
+ return crypt(password, '$%s$%s$' % (method, self.make_salt()) )
+
+ @soapmethod(String, String, _returns=String)
+ def crypt1(self, username, password):
+ """
+ GNU libc's crypt function, method 1 (SHA-160).
+ @param username the username
+ @param password the password
+ @return the encrypted password
+ """
+ return self.crypt(username, password, '1')
+
+ @soapmethod(String, String, _returns=String)
+ def crypt5(self, username, password):
+ """
+ GNU libc's crypt function, method 5 (SHA-256).
+ @param username the username
+ @param password the password
+ @return the encrypted password
+ """
+ return self.crypt(username, password, '5')
+
+ @soapmethod(String, String, _returns=String)
+ def crypt6(self, username, password):
+ """
+ GNU libc's crypt function, method 6 (SHA-512).
+ @param username the username
+ @param password the password
+ @return the encrypted password
+ """
+ return self.crypt(username, password, '6')
+
+application = CryptService()
+
+if __name__=='__main__':
+ from wsgiref.simple_server import make_server
+ server = make_server('', 8000, application)
+ server.serve_forever()