Encryption-java and php hmac_sha1 results are different, please help

PHP encryption javahmac sha1 Recently encountered the problem of hmac_sha1 cross-language encryption. It only provides Java encrypted files, not PHP. I use the PHP hmac_sha1 built-in function, and the sig encryption results obtained are different. Experts are welcome to help provide the corresponding php code. The provided java classes are as follows Welcome to add QQ: 847036019 public abstract class Coder { public static final String KEY_SHA = “SHA”; public static final String KEY_MD5 = “MD5”; public static final char hexDigits[] = { ‘0’, ‘1’, ‘2’, ‘ 3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’ }; public static final String KEY_MAC = “HmacSHA1”; public static byte[] decryptBASE64(String key) throws Exception { return (new BASE64Decoder()).decodeBuffer( key); } /** * Initialize HMAC key */ public static String initMacKey() throws Exception { KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_MAC); SecretKey secretKey = keyGenerator.generateKey(); return encryptBASE64(secretKey.getEncoded()); } /** * HMAC encryption* / public static byte[] encryptHMAC(byte[] data, String key) throws Exception { SecretKey secretKey = new SecretKeySpec(decryptBASE64(key), KEY_MAC); Mac mac = Mac.getInstance(secretKey.getAlgorithm()); mac.init (secretKey); return mac.doFinal(data); } public static void main(String[] args) { try { String param = ”; String appkey = ”; byte[] bytes = Coder.encryptHMAC((param) .getBytes(“utf-8”), appkey);//[‘-115′,’-101′,’97’,’-26′,’-80′,’-109′,’-92′, ’33’,’-6′,’71’,’-122′,’-64′,’-17′,’-29′,’-101′,’-53′,’88’,’-93 ‘,’-22′,’-104′] String…

gitlab reset password

I want to use KDevelop to learn Java, please help, thank you!

php Write your review! Come on, watch it all Member login | User registration Recommended reading php gitlab reset password I didn’t learn Ruby very much, and I forgot the rootpassword of the gitlab I built myself. Fortunately, I saw this post and tried it http:roland.kierkels.netgitreset-your-git… [detailed] Crayon Shin-chan 2023-10-17 22:22:07 sum Chapter 8 Using External and Internal Links 8.1 Use the web address LearnAboutafricanelephants. … [detailed] Crayon Shin-chan 2023-10-17 21:55:36

java-high score, please help, who knows how to convert PhP code into Java code?

javaphp <?php$prize_arr = array( ‘0’ => array(‘id’=>1,’prize’=>’tablet’,’ v’=>3), ‘1’ => array(‘id’=>2,’prize’=>’digital camera’,’v’=>5), ‘2’ => array(‘id’=>3,’prize’=>’speaker device’,’v’=>10), ‘3’ => array(‘id’=>4,’prize’=>’ 4G USB flash drive’,’v’=>12), ‘4’ => array(‘id’=>5,’prize’=>’Q Coin 10 Yuan’,’v’=>20), ‘5’ => array(‘id’=>6,’prize’=>’You might win next time’,’v’=>50),); foreach ($prize_arr as $key => $val) { $arr[$val[‘id’]] = $val[‘v’];} $rid = getRand($arr); /*Get the award id based on probability*/$res[‘msg’] = ($rid==6)?0:1; $res[‘prize’] = $prize_arr[$rid-1][‘prize’]; /*Win the prize*/echo json_encode($res);exit; /*Calculate probability*/function getRand ($proArr) { $result = ”; /*Total probability accuracy of probability array*/$proSum = array_sum($proArr);/*Probability array loop*/ foreach ($proArr as $key => $proCur) { /*It is equivalent to only being able to draw one of the prizes at a time. If you don’t win, you will start drawing the next prize until the end*/ $randNum = mt_rand(1, $proSum ); if ($randNum <= $proCur) { /*Indicates that if you win the prize, the prize should be reduced by one*/ $result = $key; break; } else { /*If you don’t win, you cannot draw again until Knock the next golden egg*/ $proSum -= $proCur; }}unset ($proArr);return $result; }?>

Encryption-java and php hmac_sha1 results are different, please help

PHP encryption javahmac sha1 Recently encountered the problem of hmac_sha1 cross-language encryption. It only provides Java encrypted files, not PHP. I use the PHP hmac_sha1 built-in function, and the sig encryption results obtained are different. Experts are welcome to help provide the corresponding php code. The provided java classes are as follows Welcome to add QQ: 847036019 public abstract class Coder { public static final String KEY_SHA = “SHA”; public static final String KEY_MD5 = “MD5”; public static final char hexDigits[] = { ‘0’, ‘1’, ‘2’, ‘ 3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’ }; public static final String KEY_MAC = “HmacSHA1”; public static byte[] decryptBASE64(String key) throws Exception { return (new BASE64Decoder()).decodeBuffer( key); } /** * Initialize HMAC key */ public static String initMacKey() throws Exception { KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_MAC); SecretKey secretKey = keyGenerator.generateKey(); return encryptBASE64(secretKey.getEncoded()); } /** * HMAC encryption* / public static byte[] encryptHMAC(byte[] data, String key) throws Exception { SecretKey secretKey = new SecretKeySpec(decryptBASE64(key), KEY_MAC); Mac mac = Mac.getInstance(secretKey.getAlgorithm()); mac.init (secretKey); return mac.doFinal(data); } public static void main(String[] args) { try { String param = ”; String appkey = ”; byte[] bytes = Coder.encryptHMAC((param) .getBytes(“utf-8”), appkey);//[‘-115′,’-101′,’97’,’-26′,’-80′,’-109′,’-92′, ’33’,’-6′,’71’,’-122′,’-64′,’-17′,’-29′,’-101′,’-53′,’88’,’-93 ‘,’-22′,’-104′] String…

javascript-Configure Apache to point to different directories for different root domain names, please help!  !  !  !

javascript-Configure Apache to point to different directories for different root domain names, please help! ! ! !

First I simulated 2 domain names, as shown in the figure Then I pointed to different directories for the two root domain names, as shown in the figure Then sudo apachectl restart, and finally, try to access, but the result is not working, please tell me where I went wrong? Permissions are also given Reply content: First I simulated 2 domain names, as shown in the figure Then I pointed to different directories for the two root domain names, as shown in the figure Then sudo apachectl restart, and finally, try to access, but the result is not working, please tell me where I went wrong? Permissions are also given 403 Forbidden? Apache I have not used it, but I encountered a 403 error when using Nginx reverse proxy on Mac. The reason is: When the user needs to obtain a file, each of its parent folders need to be It only works if you have executable permission (x), so the solution is: chmod -R o+x You can try to see if it can be solved, I hope it will be helpful~ Update: I see you added to the question and said that permissions are also given (read and write),…

JavaScript controls the background color of the read-only text box in the jsp web page – something went wrong, please help!

jsp web page code: Javascript code in js file function checkreadonly() { var txt=document.getElementsByTagName(“input”); for(var i=0;i<txt.length;i++) { var txttype=txt[i].type; var txtstyle=txt[i].style; var txtname=txt[i].name; if(txttype=="text") { if(txtname.readOnly= "true") { txtstyle.backgroundColor="#EBEBE4"; } else { txtstyle.backgroundColor="white"; } } } } Result Picture (Originally, the background color of the first read-only text box should have turned gray, but the other two non-read-only text boxes also turned gray. ): Please give me some advice, thank you very much! ! !

Please help, I don’t know what went wrong in java test connection SQL2008.

Please help, I don’t know what went wrong in java test connection SQL2008.

I followed the tutorial at http://blog.163.com/jackie_howe/blog/static/19949134720125173539380/. Code used package pkg; import java.sql.*; public class Main { public static void main(String [] args) { String driverName=”com.microsoft.sqlserver.jdbc.SQLServerDriver”; String dbURL=”jdbc:sqlserver://localhost:1433;DatabaseName=.”; String userName=”sa”; String userPwd=”123456″; try { Class.forName(driverName); System.out.println(“Loading driver successfully!”); }catch(Exception e){ e.printStackTrace(); System.out.println(“Loading driver failed!”); } try{ Connection dbCOnn=DriverManager.getConnection(dbURL,userName,userPwd); System.out.println(“Connect to database successfully!”); }catch(Exception e) { e.printStackTrace(); System.out.print(“SQL Server connection failed!”); } } } Console display Driver loading successful! com.microsoft.sqlserver.jdbc.SQLServerException: Unable to open the database “.” requested by the login. Login failed. ClientConnectionId:82c44bfe-3a37-4fc5-bb3c-eaf805902c54 SQL Server connection failed! at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254) at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84) at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2908) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at pkg.Main.main(Main.java:21) I am doing graduation project, please help. 9 solutions #1 DatabaseName=. Try changing it to DatabaseName=master. In sqlserver, the instance can be used., but the database name does not have this usage. #2 If it becomes available after changing to master, then change master back to your user database. #3 Quoting the reply from DBA_Huangzj on the 2nd floor: If it becomes available after changing to master, then change master back to your user database. The computer I used last night…

The bottleneck of Java programmers, please help.

The bottleneck of Java programmers, please help.

Background: As a Java Web developer, I have not been working for a long time, less than a year. I am not very talented, but a hard-working person. I can basically do all the things in the development process, including various front-end and back-end frameworks. I also use it. I personally feel that my understanding of JavaSE is relatively deep (just my own feeling). I also feel good about those common design patterns and programming ideas. I feel that I understand it deeply. In fact, I don’t understand it deeply. JDK I have also studied some key source codes and can basically understand them. I guess as a coder, these skills may be basically enough just to write some business logic code. In fact, it has not hindered the company, although I have done it. The technical content of the project is not high. The most important thing is to learn something that you don’t know how to do, and to look at the API. I still feel that it is relatively fast to learn new frameworks or unused APIs, such as those small ones. The js plug-in can basically be used at a glance. Of course, it is not…

java.lang.NoSuchMethodError:main error, please help!

java.lang.NoSuchMethodError: main Exception in thread “main” ———————————-The code is as follows import java.io.*; public class Util extends Object {                             Public static int RunThis(String args) { Runtime rt = Runtime.getRuntime(); int rc = -1;          try               { Process p = rt.exec(args); int bufSize = 4096; BufferedInputStream bis = new BufferedInputStream(p.getInputStream(), bufSize); int len; ​ ​ byte buffer[] = new byte[bufSize];             While ((len = bis.read(buffer, 0, bufSize)) != -1) System.out.write(buffer, 0, len);            rc = p.waitFor();           } ​​​​catch (Exception e)                          {            e.printStackTrace();             rc = -1;           }          finally               { Return rc ;        }                                               } 16 solutions #1 There is no main function, main function is required to run #2 This is not the problem, ls can help debug it. #3 There is too little content, I don’t know what exactly is wrong! Post more stuff! #4 There is no main function #5 java.lang.NoSuchMethodError: main Exception in thread “main” There is no main function Run directly The main function is the entry point of the program #6 It’s definitely because there is no main function. #7 What is the procedure? Debugging~I don’t know what you need to input? #8 Util, looking…

Use java statements to write points in three-dimensional space. The example is as follows: Please help me add comments~~Brothers and sisters, please help.

Use java statements to write points in three-dimensional space. The example is as follows: Please help me add comments~~Brothers and sisters, please help public class Point { private double x; private double y; private double z; //Default origin without parameters public Point() { this(0, 0, 0); } //Constructor specifies coordinates public Point(double x, double y, double z) { this.x = x; this. y = y; this.z = z; } public static void main(String args[]){ Point p = new Point(1, 1, 1);//Construction, 1, 1, 1 point, distance from the far point It is the root number 3,1. How to use Java to write two classes, Point2D and Point3D, to represent points in two-dimensional space and three-dimensional space? /* * Project: Space point * Author: searchpcc(xixi,Level 11,20112866) * File: TuXing.java * Instruction: main program * Time: 2012-11-07 */ class Point2D{ int x; int y; public Point2D(){ } public Point2D(int x, int y){ this.x = x; this.y = y; } public void offset(int a, int b){ x = a; y = b; this.x = this.x + 1; this.y = this.y + 1; System.out.print(x); System.out.print(y); } double distan(Point2D p1, Point2D p2){ return(Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))); } } class Point3D extends Point2D{ int z; public Point3D(int x, int…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索