Commits

Kota UENISHI committed e78a265

crypt(2)

Comments (0)

Files changed (4)

+#include <stdio.h>
+#include <string>
+#include <stdlib.h>
+#include <iostream>
+
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE
+#endif
+#include <unistd.h>
+
+using namespace std;
+static const string SALT_BASE("$6$aaaaaa$");
+
+string get(const string& key){
+  char * h = crypt(key.c_str(), SALT_BASE.c_str());
+  string hash(h+SALT_BASE.size());
+  printf("%s\n", hash.c_str());
+  free(h);
+  return hash;
+}
+
+
+int main(){
+  string key("hogehoge");
+  cout << get(key) << endl;
+  return 0;
+}

haskell/OMakefile

 HC_ASFLAGS +=
 HC_LDFLAGS +=
 HC_INCLUDES +=
-HC_OPTS = -threaded -cpp -package parsec
+HC_OPTS = -threaded -cpp -package parsec #-XTypeSynonymInstances
 
 ################################################
 # Uncomment the following section if you want
 #
 
 HCFILES[] =
-    mylang
-#    file1
-#    main
-#
-MAIN = mylang
+    JSONClass
+    json
+#    ApplicativeParsec
+
+MAIN = json
 
 .DEFAULT: $(HCProgram $(MAIN), $(HCFILES))
 	./$(MAIN)
 
 main = putStrLn $ show $ parse_csv "'hoge',\"aaa asfd \"\nha ge, ge\n"
 
-data Expr a = Expr a
-            | Term a 
-            | EOF
-
 csvFile = endBy line eol
 
 line = sepBy cell (char ',')

haskell/mylang.hs

             | Term a 
             | EOF
 
-csvFile = endBy line eol
+jsonFile = endBy line eol
 
 line = sepBy cell (char ',')
 cell = quotedCell <|> quotedCell2 <|> many (noneOf ",\n\r")
       <|> string "\r" 
       <?> "couldn't find eol"
 
-parse_csv input = parse csvFile "(unknown)" input
+parse_json input = parse jsonFile "(unknown)" input