如何生成 MD5哈希?

Is there any method to generate MD5 hash of a string in Java?

转载于:https://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash

weixin_41568183
零零乙 Md5 hashing is unsafe in most cases! Please choose a deep crypt algorithm!! I But If you want to online hashing then you can use this tool
2 年多之前 回复
csdnceshi51
旧行李 I don't see any mention of cryptography in this question.
大约 3 年之前 回复
csdnceshi58
Didn"t forge Using MD5 is not correct solution
接近 4 年之前 回复
csdnceshi53
Lotus@ Nice short working code with Hex formatting here : dzone.com/articles/get-md5-hash-few-lines-java
接近 4 年之前 回复
csdnceshi64
游.程 "unsuitable for further use...and most U.S. government applications now require the SHA-2 family of hash functions."
4 年多之前 回复
csdnceshi52
妄徒之命 what is good then?
接近 5 年之前 回复
csdnceshi74
7*4 MD5 might be unsafe as a one-way security feature, but it is still good for generic checksum applications.
5 年多之前 回复
csdnceshi70
笑故挽风 It isn't duplicate.
接近 7 年之前 回复
csdnceshi63
elliott.david Keep in mind that according to the recent research "MD5 should be considered cryptographically broken and unsuitable for further use". en.wikipedia.org/wiki/MD5
大约 7 年之前 回复
csdnceshi76
斗士狗 stackoverflow.com/questions/304268/…
7 年多之前 回复

30个回答

java.security.MessageDigest is your friend. Call getInstance("MD5") to get an MD5 message digest you can use.

weixin_41568126
乱世@小熊 This does not answer the question, it's just a couple of links. stackoverflow.com/help/how-to-answer
2 年多之前 回复
weixin_41568196
撒拉嘿哟木头 I believe back when I wrote this I thought about an "finalized" & "ready for consumption" InputStream that would be fully drained by the static method. Any necessary state would be saved in the method body.
接近 4 年之前 回复
weixin_41568134
MAO-EYE and what would it do with the bytes that it read from that stream, throw them away?
大约 4 年之前 回复
weixin_41568196
撒拉嘿哟木头 Makes sense. I guess you wouldn't always want to move around byte arrays with multiple Gigabytes! Still, just let it take a stream.
接近 5 年之前 回复
csdnceshi56
lrony* MessageDigest allows you to input the data in chunks. That wouldn't be possible with a static method. Although you can argue they should have added one anyway for convenience when you can pass all the data at once.
接近 5 年之前 回复
weixin_41568196
撒拉嘿哟木头 From a naive perspective converting a string or bytes to an md5 hash looks like the perfect example for something you'd do with a static method. You want one transformation and nothing else. The need for a getInstance is surprising, but can be explained with the potential lack of the algorithm on your JVM. But even the possibility of having any kind of side effect (on the state of messageDigest) is simply very surprising. Look below at the answer of lutzh. Now that looks like something sane you'd expect (but it's is still insane under the hood with creating new instances for every hash!).
5 年多之前 回复
weixin_41568184
叼花硬汉 well, you are mutating it (i.e. calling methods that do not return values but cause other methods to return different values) so until proven otherwise you should always assume that it’s not thread-safe to do so.
接近 6 年之前 回复
weixin_41568208
北城已荒凉 why should we expect to have to know about MessageDigest's internal state?
接近 6 年之前 回复
weixin_41568184
叼花硬汉 It uses multiple methods to mutate its internal state. How can the lack of thread safety be surprising at all?
大约 7 年之前 回复
csdnceshi80
胖鸭 One thing that's not mentioned here, and caught me by surprise. The MessageDigest classes are NOT thread safe. If they're going to be used by different threads, just create a new one, instead of trying to reuse them.
大约 7 年之前 回复

Found this:

public String MD5(String md5) {
   try {
        java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
        byte[] array = md.digest(md5.getBytes());
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; ++i) {
          sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
       }
        return sb.toString();
    } catch (java.security.NoSuchAlgorithmException e) {
    }
    return null;
}

on the site below, I take no credit for it, but its a solution that works! For me lots of other code didnt work properly, I ended up missing 0s in the hash. This one seems to be the same as PHP has. source: http://m2tec.be/blog/2010/02/03/java-md5-hex-0093

csdnceshi59
ℙℕℤℝ For an example of the character set... (use UTF-8, that is the best and most compatible in my opinion)... byte[] array = md.digest(md5.getBytes(Charset.forName("UTF-8")));
5 年多之前 回复
csdnceshi62
csdnceshi62 "MD5" is not an encoding, it is a message digest algorithm (and not one which should be used in new applications). An encoding is an algorithm pair which transforms bytes to strings and strings to bytes. An example would be "UTF-8", "US-ASCII", "ISO-8859-1", "UTF-16BE", and similar. Use the same encoding as every other party which calculates a hash of this string, otherwise you'll get different results.
6 年多之前 回复
weixin_41568196
撒拉嘿哟木头 does MessageDigest.getInstance("MD5"); not enough? I tried to add "MD5" in getBytes() but it returned an error
6 年多之前 回复
csdnceshi62
csdnceshi62 You should specify the encoding to be used in getBytes(), otherwise your code will get different results on different platforms/user settings.
接近 9 年之前 回复

You might also want to look at the DigestUtils class of the apache commons codec project, which provides very convenient methods to create MD5 or SHA digests.

csdnceshi53
Lotus@ +1. you can download this from here commons.apache.org/codec
8 年多之前 回复
csdnceshi68
local-host Should be in the central Maven repositories, unless I'm going crazy: groupId=commons-codec artifactId=commons-codec version=1.5
8 年多之前 回复
weixin_41568127
?yb? Can't find it in maven repos either. Grrrr.
8 年多之前 回复
csdnceshi57
perhaps? However there is no easy way to get the DigestUtils class into your project without adding a ton of libs, or porting the class "per hand" which requires at least two more classes.
接近 9 年之前 回复
csdnceshi54
hurriedly% In particular, the methods which return "safe" encoded representations of the byte data in string form.
11 年多之前 回复

The MessageDigest class can provide you with an instance of the MD5 digest.

When working with strings and the crypto classes be sure to always specify the encoding you want the byte representation in. If you just use string.getBytes() it will use the platform default. (Not all platforms use the same defaults)

import java.security.*;

..

byte[] bytesOfMessage = yourString.getBytes("UTF-8");

MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(bytesOfMessage);

If you have a lot of data take a look at the .update(byte[]) method which can be called repeatedly. Then call .digest() to obtain the resulting hash.

csdnceshi69
YaoRaoLov Then how do u convert this thedigest to a string so that we can insert it in mysql ?
2 年多之前 回复
csdnceshi69
YaoRaoLov This was very easy and simple I would recommend this for all of the visitors
2 年多之前 回复
csdnceshi66
必承其重 | 欲带皇冠 I needed the hex string to save in db. dac2009 has posted the solution for this
4 年多之前 回复
csdnceshi56
lrony* : there is no such thing as a "pure string", unless you meant the serialized contents of the Java object itself. Please refer to the previously posted link to Joel On Software.
4 年多之前 回复
csdnceshi66
必承其重 | 欲带皇冠 and what about if I want the pure string ?
4 年多之前 回复
csdnceshi63
elliott.david This topic is also useful if you need to convert the resulting bytes to hex string.
大约 8 年之前 回复
weixin_41568110
七度&光 Apache commons coded use UTF-8 and this guys are knowing what they are doing
9 年多之前 回复
csdnceshi74
7*4 (see joelonsoftware.com/articles/Unicode.html for much better rationale and explanation)
11 年多之前 回复
csdnceshi74
7*4 Why, why, why do you explicitly warn to always specify the encoding and then explicitly pick the worst one available? Using Latin1, you're setting yourself up for very subtle bugs (it seems especially pointless when you can use UTF-8 just as easily).+1 for "specify encoding", -2 for "latin1"
11 年多之前 回复
weixin_41568127
?yb? Is there any reason why you don't want to use "UTF-8" here? UTF-8 can represent all characters and if you use LATIN1 here, it would result in many, many non-Latin Strings producing exactly the same digest, which is far from optimal.
11 年多之前 回复
csdnceshi54
hurriedly% “LATIN1” != “ASCII” (or “US-ASCII”). ASCII is a 7-bit character set, Latin1 is an 8-bit character set. They are not the same.
11 年多之前 回复

If you actually want the answer back as a string as opposed to a byte array, you could always do something like this:

String plaintext = "your text here";
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
  hashtext = "0"+hashtext;
}
csdnceshi72
谁还没个明天 Minor nitpick: m.reset() isn't necessary right after calling getInstance. More minor: 'your text here' requires double-quotes.
大约 9 年之前 回复
csdnceshi77
狐狸.fox Not true, the BigInteger.toString method will return the full number in the base specified. 0x0606 will be printed as 606, just trailing zeros are omitted,
9 年多之前 回复

Here is how I use it:

final MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(string.getBytes(Charset.forName("UTF8")));
final byte[] resultByte = messageDigest.digest();
final String result = new String(Hex.encodeHex(resultByte));

where Hex is: org.apache.commons.codec.binary.Hex from the Apache Commons project.

weixin_41568196
撒拉嘿哟木头 I would replace last line with this: String result = Hex.encodeHexString(resultByte);
大约 9 年之前 回复
weixin_41568174
from.. If you use Apache Commons Codec anyway you can use: commons.apache.org/codec/api-release/org/apache/commons/codec/…
9 年多之前 回复

I've found this to be the most clear and concise way to do it:

MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(StandardCharsets.UTF_8.encode(string));
return String.format("%032x", new BigInteger(1, md5.digest()));
csdnceshi65
larry*wei Beware this won't work for Android if you're using API level < 19, but you just need to change the second line with md5.update(string.getBytes("UTF-8")); This will add yet another checked exception to handle, though...
2 年多之前 回复
csdnceshi55
~Onlooker Great. It doesn't fall into the trap of cutting leading zeros.
接近 4 年之前 回复

Another option is to use the Guava Hashing methods:

Hasher hasher = Hashing.md5().newHasher();
hasher.putString("my string");
byte[] md5 = hasher.hash().asBytes();

Handy if you are already using Guava (which if you're not, you probably should be).

csdnceshi67
bug^君 don't forget to insert the charset like 'Hashing.md5().hashString("my string", Charsets.UTF_8).asBytes()'
大约 4 年之前 回复
csdnceshi51
旧行李 This worked perfectly, awesome
大约 4 年之前 回复
csdnceshi70
笑故挽风 or using one of the shortcut methods: Hashing.md5().hashString("my string").asBytes();
4 年多之前 回复

Another implementation:

import javax.xml.bind.DatatypeConverter;

String hash = DatatypeConverter.printHexBinary( 
           MessageDigest.getInstance("MD5").digest("SOMESTRING".getBytes("UTF-8")));
weixin_41568196
撒拉嘿哟木头 there is no MD5 without hex (see ietf.org/rfc/rfc1321.txt) , to get it in lowercase simply add .toLower(). Compare the results to the examples in e.g. en.wikipedia.org/wiki/MD5 then you will have a better chance to believe that Javas library code is correct.
接近 3 年之前 回复
csdnceshi54
hurriedly% Unless I'm mistaken this returns always in uppercase which will not align with md5's made without using hex. Not even really sure it is a true md5
接近 3 年之前 回复
csdnceshi70
笑故挽风 Only one-liner I've seen that doesn't use an external library.
3 年多之前 回复

My not very revealing answer:

private String md5(String s) {
    try {
        MessageDigest m = MessageDigest.getInstance("MD5");
        m.update(s.getBytes(), 0, s.length());
        BigInteger i = new BigInteger(1,m.digest());
        return String.format("%1$032x", i);         
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return null;
}
csdnceshi63
elliott.david and String.format("%1$032X", big) to have an uppercase format
大约 6 年之前 回复
csdnceshi63
elliott.david nice, +1 for String.format("%1$032x", i)
大约 6 年之前 回复
csdnceshi53
Lotus@ good, no external libraries required
大约 6 年之前 回复
共30条数据 1 3 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java 利用md5生成带秘钥的哈希值 有相应的函数吗

哪位大牛知道php的 hash_hmac ( string $algo , string $data , string $key [, bool $raw_output = false ] ),在java中有对应的函数吗

如何使用具有多个用户定义结构数据库的md5哈希自定义Laravel 5.8身份验证?

<div class="post-text" itemprop="text"> <p>My case is like this, making a new application from an old application that already exists. The new application as an independent application uses its own database, but for authenticating credentials it uses the old application database. So I use a custom auth, but I'm having problems. My problem when checking the <code>Auth::check()</code> value is <code>true</code> but when redirected to the home page, the Expired Page appears. After I check <code>Auth::check()</code> again, the result is <code>false</code>. I feel there is something wrong with implementing UserProvider, but I haven't managed to implement it yet. I have modified the environment for multiple databases, and have successfully connected.</p> <p>I have modified the environment for multiple databases, and have successfully connected. I've changed the <strong>config\database.php</strong> file. I modified and added the database connection used. Then I modified the <strong>config\auth.php</strong>. Credentials for logging in using "username" and "password". The "hints" field is a form of the default plain password when resetting a password. Encrypt the password using the md5 hash with the following composition:<br> <code>$password = md5(md5(&lt;input-password&gt;.salt).salt)</code></p> <p>The App namespace is <code>FKQuiz</code>.</p> <p>I've modified some files : <strong>config\auth.php</strong></p> <pre><code>'defaults' =&gt; [ 'guard' =&gt; 'siakad', 'passwords' =&gt; 'sc_user', ], 'guards' =&gt; [ 'siakad' =&gt; [ 'driver' =&gt; 'session', 'provider' =&gt; 'usersiakad', ], 'api-siakad' =&gt; [ 'driver' =&gt; 'token', 'provider' =&gt; 'usersiakad', 'hash' =&gt; false, ], ], 'providers' =&gt; [ 'usersiakad' =&gt; [ 'driver' =&gt; 'eloquent', 'model' =&gt; FKQuiz\Models\UserSiakad::class, ], ], 'passwords' =&gt; [ 'sc_user' =&gt; [ 'provider' =&gt; 'usersiakad', 'expire' =&gt; 30, ], ], </code></pre> <p>Table structure :</p> <pre><code>+--------+----------+----------+--------------+----------------+---------------+ | userid | username | password | hints | salt | tokenreset | +--------+----------+----------+--------------+----------------+---------------+ </code></pre> <p>Modified <em>app\Models\UserSiakad.php</em></p> <pre><code>&lt;?php namespace FKQuiz\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\Authenticatable as AuthenticableContract; use Illuminate\Auth\Authenticatable as AuthenticableTrait; use Illuminate\Foundation\Auth\User as Authenticatable; class UserSiakad extends Authenticatable implements AuthenticableContract { use Notifiable, AuthenticableTrait; protected $connection = 'pgsiakad'; protected $table = 'gate.sc_user'; protected $hidden = [ 'password', 'salt', ]; public function getAuthPassword() { return bcrypt($this-&gt;password); } protected function credentials(Request $request) { return [ $this-&gt;username() =&gt; $request-&gt;get('username'), 'password' =&gt; md5($request-&gt;get('password')) ]; } public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; return $this-&gt;hasher-&gt;check($plain, $user-&gt;getAuthPassword()); } } </code></pre> <p>File <strong>app\Http\Controllers\AuthSiakad\LoginController.php</strong></p> <pre><code>&lt;?php namespace FKQuiz\Http\Controllers\AuthSiakad; use FKQuiz\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use FKQuiz\Models\UserSiakad; class LoginController extends Controller { public function __construct() { $this-&gt;middleware('guest')-&gt;except('logout'); } public function username() { return 'username'; } public function showLoginForm() { return view('authSiakad.login'); } public function login(Request $request) { $u = UserSiakad::where('username', '=', $request-&gt;username)-&gt;first(); $s = $u-&gt;salt; $credentials = [ $this-&gt;username() =&gt; $request-&gt;get('username'), 'password' =&gt; md5(md5($request-&gt;get('password').$s).$s) ]; if (Auth::attempt($credentials)){ // If login succesful, then redirect to their intended location return redirect()-&gt;intended(route('home')); } // If Unsuccessful, then redirect back to the login with the form data return redirect()-&gt;back()-&gt;withInput($request-&gt;only('username', 'remember')); } protected function credentials(Request $request) { return [ $this-&gt;username() =&gt; $request-&gt;get('username'), 'password' =&gt; md5($request-&gt;get('password')) ]; } public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; return $this-&gt;hasher-&gt;check($plain, $user-&gt;getAuthPassword()); } } </code></pre> <p>File <strong>routes\web.php</strong></p> <pre><code>Route::get('/', function () { return view('welcome'); }); Route::get('/', 'HomeController@index')-&gt;name('home'); Route::get('/login', 'AuthSiakad\LoginController@showLoginForm')-&gt;name('login'); Route::post('/login', 'AuthSiakad\LoginController@login')-&gt;name('login.submit'); </code></pre> <p>File <strong>app\Http\Controllers\HomeController.php</strong></p> <pre><code>&lt;?php namespace FKQuiz\Http\Controllers; use Illuminate\Http\Request; class HomeController extends Controller { public function __construct() { $this-&gt;middleware('auth:siakad'); } public function index() { return view('home'); } } </code></pre> <p>When logging in, I cannot successfully enter the Home page that is directed to LoginController.php. After I check, <code>Auth::attempt()</code> returns the value <code>true</code> but <code>Auth::check()</code> is <code>false</code> so that when entering HomeController.php, the credential entered is <code>Auth::guest() = true</code>. And the value <code>Auth::user()</code> looks like this:</p> <pre><code>UserSiakad {#229 ▼ #connection: "pgsiakad" #table: "gate.sc_user" #hidden: array:2 [▼ 0 =&gt; "password" 1 =&gt; "salt" ] #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:16 [▼ "userid" =&gt; 3747 "username" =&gt; "1522315009" "password" =&gt; "aa184593e6511e6d9983ba536d36cdb8" "hints" =&gt; "05051994" "salt" =&gt; "1pBAKNsSczk2aZLFAg8cgJwIpNyo7a" "tokenreset" =&gt; null ] #original: array:16 [▼ "userid" =&gt; 3747 "username" =&gt; "1522315009" "password" =&gt; "aa184593e6511e6d9983ba536d36cdb8" "hints" =&gt; "05051994" "salt" =&gt; "1pBAKNsSczk2aZLFAg8cgJwIpNyo7a" "tokenreset" =&gt; null ] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #visible: [] #fillable: [] #guarded: array:1 [▼ 0 =&gt; "*" ] #rememberTokenName: "remember_token" } </code></pre> <p>I feel there is something wrong with implementing UserProvider, but I haven't managed to implement it yet. So, what is the solution? Thanks</p> </div>

关于C语言中MD5算法怎么应用

在项目中要给一个成员变量AuthenticatorSource赋值,然后阅读文档后有如下说明: AuthenticatorSource:用于鉴别源地址。其值通过单向MD5hash计算得出,表示如下: AuthenticatorSource = MD5(Source_Addr+9 字节的0 +shared secret+timestamp) Sharedsecret 由中国移动与源地址实体事先商定,timestamp格式为:MMDDHHMMSS,即月日时分秒,10位。 第一次接触这个东东,有点蒙,在网上查了下说是MD5l加密算法,但是没有找到相关应用。请问是不是MDY5()就是一个函数,那么它在哪个头文件中呢。还有使用的时候要怎么用,可以把这个代码写下来吗,谢谢大家。 记得是两个问题噢: 1,在哪个头文件中 2,如何使用,求代码示例

CRAM-MD5验证期间的不同哈希

<div class="post-text" itemprop="text"> <p>As an exercise, I'm trying to implement a mock SMTP server with CRAM-MD5 authentication in Go (without following RFC 2195, since it looks like it doesn't matter to the client what format the pre-hashed challenge is in; I also assume there is only one user "bob" with password "pass"). But I can't seem to get it right as the hash in response is always different from what I have on the server. I send the email using Go as such (running it as a separate package):</p> <pre><code>{...} smtp.SendMail("localhost:25", smtp.CRAMMD5Auth("bob", "pass"), "bob@localhost", []string{"alice@localhost"}, []byte("Hey Alice! ")) {...} </code></pre> <p>Here's what I do when I get the authentication acknowledgement from the client:</p> <pre><code>{...} case strings.Contains(ms, "AUTH CRAM-MD5"): rndbts = make([]byte, 16) // Declared at package level b64b := make([]byte, base64.StdEncoding.EncodedLen(16)) rand.Read(rndbts) base64.StdEncoding.Encode(b64b, rndbts) _, err = conn.Write([]byte(fmt.Sprintf("334 %x ", b64b))) {...} </code></pre> <p>And this is what I do with the client's response: </p> <pre><code>{...} { ms = strings.TrimRight(ms, " ") // The response to the challenge ds, _ := base64.StdEncoding.DecodeString(ms) s := strings.Split(string(ds), " ") login := s[0] // I can get the login from the response. h := hmac.New(md5.New, []byte("pass")) h.Write(rndbts) c := make([]byte, 0, ourHash.Size()) // From smtp/auth.go, not sure why we need this. validPass := hmac.Equal(h.Sum(c), []byte(s[1])) {...} } {...} </code></pre> <p>And the <code>validPass</code> is never <code>true</code>. I omitted error handling from the excerpts for brevity, but they're there in the actual code (though they're always <code>nil</code>). Why are the hashes different? I have looked at the source code for net/smtp, and it seems to me that I'm going in the right direction, but not quite.</p> </div>

那位大神能把我这个Java的md5的加密方法写个php版本哦,感激噢!

那位大神能把我这个Java的md5的加密方法写个php版本哦,感激噢,Java代码如下! 写这个的人 描述的思路如下 1.将秘钥、源串分别转换byte数组 2.声明2个64位数组 将key的byte数组分别做异或运算填充进去 并分别补充 54、92 补满64长度 3.获得md5摘要算法的MessageDigest 对象 4.使用其中一个数组及源串的数组更新MessageDigest 摘要 完成哈希计算 5.重置摘要 6.使用另一个数组更新摘要 使用4中结果 从0到16开始更新摘要 完成哈希计算 7.转换字符串 public String cryptMd5(String source, String key) { byte[] k_ipad = new byte[64]; byte[] k_opad = new byte[64]; byte[] keyb; byte[] value; try { byte[] keyb = key.getBytes("UTF-8"); value = source.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { byte[] value; keyb = key.getBytes(); value = source.getBytes(); } Arrays.fill(k_ipad, keyb.length, 64, 54); Arrays.fill(k_opad, keyb.length, 64, 92); for (int i = 0; i < keyb.length; i++) { k_ipad[i] = (byte)(keyb[i] ^ 0x36); k_opad[i] = (byte)(keyb[i] ^ 0x5C); } MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; } md.update(k_ipad); md.update(value); byte[] dg = md.digest(); md.reset(); md.update(k_opad); md.update(dg, 0, 16); dg = md.digest(); return toHex(dg); } public static String toHex(byte[] input) { if (input == null) { return null; } StringBuffer output = new StringBuffer(input.length * 2); for (int i = 0; i < input.length; i++) { int current = input[i] & 0xFF; if (current < 16) output.append("0"); output.append(Integer.toString(current, 16)); } return output.toString(); }

继续求助第二波,那位大神能把这个Java md5的方法写个php版的,得加密结果一致的,谢谢了!

继续求助第二波,那位大神能这个Java md5的方法写个php版的,得加密结果一致的,谢谢了,第一波有位达人写了一个了,但是加密结果不一样,大家可以参考下! java方法描述的思路如下 1.将秘钥、源串分别转换byte数组 2.声明2个64位数组 将key的byte数组分别做异或运算填充进去 并分别补充 54、92 补满64长度 3.获得md5摘要算法的MessageDigest 对象 4.使用其中一个数组及源串的数组更新MessageDigest 摘要 完成哈希计算 5.重置摘要 6.使用另一个数组更新摘要 使用4中结果 从0到16开始更新摘要 完成哈希计算 7.转换字符串 方法如下 public String cryptMd5(String source, String key) { byte[] k_ipad = new byte[64]; byte[] k_opad = new byte[64]; byte[] keyb; byte[] value; try { byte[] keyb = key.getBytes("UTF-8"); value = source.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { byte[] value; keyb = key.getBytes(); value = source.getBytes(); } Arrays.fill(k_ipad, keyb.length, 64, 54); Arrays.fill(k_opad, keyb.length, 64, 92); for (int i = 0; i < keyb.length; i++) { k_ipad[i] = (byte)(keyb[i] ^ 0x36); k_opad[i] = (byte)(keyb[i] ^ 0x5C); } MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { return null; } md.update(k_ipad); md.update(value); byte[] dg = md.digest(); md.reset(); md.update(k_opad); md.update(dg, 0, 16); dg = md.digest(); return toHex(dg); } public static String toHex(byte[] input) { if (input == null) { return null; } StringBuffer output = new StringBuffer(input.length * 2); for (int i = 0; i < input.length; i++) { int current = input[i] & 0xFF; if (current < 16) output.append("0"); output.append(Integer.toString(current, 16)); } return output.toString(); } 下面这个是上次提问达人写的,加密结果和Java的还是不一致 function cryptMd5($source, $key) { if(! mb_check_encoding($source, 'utf-8')) $source = mb_convert_encoding($source, "utf-8", "auto"); if(! mb_check_encoding($key, 'utf-8')) $key = mb_convert_encoding($key, "utf-8", "auto"); $k_ipad = str_pad($key, 64, chr(54)); $k_opad = str_pad($key, 64, chr(92)); for($i=0; $i<strlen($key); $i++) { $k_ipad{$i} = $key{$i} ^ chr(0x36); $k_opad{$i} = $key{$i} ^ chr(0x5c); } $dg = md5($source . substr($k_ipad, strlen($source)), true); $dg = md5(substr($dg, 0, 16) . substr($k_opad, 16), true); return bin2hex($dg); }

从一组变量生成哈希字符串

<div class="post-text" itemprop="text"> <p>How can I generate a hash with let's say md5 from set of mixed variables?</p> <p>The variables can be of any type, like multidimensional arrays, objects, integers etc.</p> <p>The idea is to be able to identify within a function if the given arguments are exactly the same as the ones in the previous function call.</p> <p>This would work but not for all type of vars:</p> <pre><code>$args = func_get_args(); $args = array_values($args); echo md5(implode('', $args)); </code></pre> </div>

缓存模板分析器生成的页面 - 包括哈希排名

<div class="post-text" itemprop="text"> <p>I am currently working on a template parser that takes a load of variables (including arrays) and loops though a provided template searching and replacing them with PHP, then caches this PHP and sends it to the browser.</p> <p>However I would like to add another layer of caching where it caches the HTML generated by the PHP and am wondering the best way to do it and whether it would be worth it?</p> <p>The only way I can think to implement this would be to md5 all the variables that the generated PHP was given and then check against a list of HTML files as to whether the variables have the same hash, however I imagine this would be very cpu intensive and a complete waste of time.</p> <p>Would it be a waste of time? Is there a better way to do this?]</p> <p>.</p> <p><strong>Edit: Ranked List of All PHP's Hashing Algorhythms - Generated Fairly</strong></p> <p>So I created a fair comparison of all of PHP's hashing algorithms, included here for interest.</p> <p>For anyone interested here is a ranked list of PHP's hashing algorithms tested with 10000 hashes of a shared (per loop) random 15 digit number and a random 500 letter string. </p> <p>I also include the possibilities that that hash has, an example of the hash and the average rank of that hash.</p> <pre><code>Hash Time Rank 1 - crc32 0.109843254089 2 - crc32b 0.112758636475 3 - md4 0.128808498383 4 - md5 0.141296863556 5 - sha1 0.151764154434 6 - adler32 0.152633905411 7 - tiger192,3 0.185636281967 8 - tiger128,3 0.192178249359 9 - ripemd128 0.192563295364 10 - tiger160,3 0.195315361023 11 - ripemd256 0.201178789139 12 - salsa10 0.211281776428 13 - tiger160,4 0.215661048889 14 - tiger192,4 0.215940475464 15 - tiger128,4 0.218608856201 16 - haval224,3 0.219294309616 17 - salsa20 0.220067501068 18 - haval192,3 0.220562696457 19 - sha256 0.221296072006 20 - haval160,3 0.221850395203 21 - ripemd320 0.223988294601 22 - ripemd160 0.224121570587 23 - sha224 0.225886106491 24 - haval256,3 0.229130744934 25 - haval128,3 0.235924243927 26 - haval256,4 0.267326116562 27 - haval160,4 0.269260883331 28 - haval224,4 0.270739555359 29 - haval128,4 0.272269487381 30 - haval192,4 0.272310495377 31 - haval224,5 0.300775766373 32 - haval160,5 0.301377296448 33 - haval192,5 0.302173137665 34 - haval256,5 0.302881002426 35 - haval128,5 0.305021524429 36 - sha384 0.365926265717 37 - sha512 0.37784910202 38 - gost 0.411582231522 39 - whirlpool 0.66826415062 40 - snefru256 0.866051673889 41 - snefru 0.873198509216 42 - md2 1.85310149193 Hashes Compared 1 - crc32 ab6bce26 2 - crc32b a858f80e 3 - md4 6b5f6832624aa2a62dff0e1e1ca9782c 4 - md5 651174af49d11b8a37d5af8f7ac2ebf2 5 - sha1 3da56487bf3ee10fd89bffb9de70958fcd1eccaf 6 - adler32 d7bcb36d 7 - tiger192,3 3b2f4e9ce737c55694d15a7b7de07a95f7cdc4fef200ee80 8 - tiger128,3 3b2f4e9ce737c55694d15a7b7de07a95 9 - ripemd128 3db40be35a1b4809165d4ec4c4419116 10 - tiger160,3 3b2f4e9ce737c55694d15a7b7de07a95f7cdc4fe 11 - ripemd256 465f4057308a3b278e4a5d848913f6e321724caa822f366b98971f46755769e6 12 - salsa10 cd51bb98aa8be1047b637ee729573c95e2930ea6bc89b015e1ca45b219aef9269c0bf33799eb977e49264d4dbf94a97de5020f7b40bfd9e4199c896ebaa8f041 13 - tiger160,4 a45bcd00ca9cb066cf8162985462e075f8d92fcd 14 - tiger192,4 a45bcd00ca9cb066cf8162985462e075f8d92fcd7ea1bdc8 15 - tiger128,4 a45bcd00ca9cb066cf8162985462e075 16 - haval224,3 f5a41fe0934675b8618312da94dd5dbe9f60d8558c7623cea515ac80 17 - salsa20 3132bfbd6f055ad5e12a689c0159626c564ac392ad1a70d78a9be82e2bda2a35e0aa71d9a5a2873ba8a21ce7e8f6a36724383737eb951526915625904e64c5c1 18 - haval192,3 3aab1fe0204975b8aa8612da96e05dbe6664d855487d23ce 19 - sha256 e83d87d2641712bcb4efd58c8a1dc6b8e367df83c3f144c50ac2da7827cc64fb 20 - haval160,3 ded422e0eb947ab8e1e816daeb0d65be510be655 21 - ripemd320 20545474676f7eba741e76e11e1f1c3f77c138697c7651e4277c942a14d037fcbcac969716753078 22 - ripemd160 17e1639be09e1e9b49ab0b820236721d9d87b3db 23 - sha224 da147a3194d52316c74e490eb5d521423c24906b205b97d89279aaff 24 - haval256,3 daa41fe0844675b85e8312da91dd5dbe9a60d855837623ce9c15ac80996accdb 25 - haval128,3 3ac89f795c151223b30628a62b540a9a 26 - haval256,4 4a335ea8aa07a6824db40e91f3fd8ef9f7db1b9dda25af1ec18f26412917a79a 27 - haval160,4 5f5b63a83988a98227d415910a9891f9698e259d 28 - haval224,4 5d335ea8b407a68256b40e910bfe8ef902dc1b9dec25af1eca8f2641 29 - haval128,4 25e39fd1c525679aea8e9e38ea23b593 30 - haval192,4 9a355ea8cb0aa6820bb50e91d6ff8ef99dde1b9da32aaf1e 31 - haval224,5 2e0924bd900081a2369c6cbd72e421ab9df5081cb955e9696c2bf898 32 - haval160,5 631c29bdbf9281a28f0770bdedc427ab32050d1c 33 - haval192,5 4c0b24bdaf0181a2439f6cbd21eb21ab15f7081cae57e969 34 - haval256,5 260924bd8b0081a2289c6cbd57e421ab9df5081ca755e969642bf89828617b41 35 - haval128,5 1bf3bce59369e50344439838f4391aed 36 - sha384 42c573a2f7d782ec1cea504aeac8ac2fc2333ffb944ff66352381156e473f540c5bc903e8a61ccfaa4d4b834b0774007 37 - sha512 e079e5afee4a96fef7456c5c50271daeb6bf79d5b539ab052fe0173a613d58d267ba202f5d52b4da87355e5687365895fc2cb0b3e57b195053ded6172668de02 38 - gost 14e8788685c65af29e381759550a60340330ad67637578833de02717f032638f 39 - whirlpool 122077c8adb99aef129edcfd330908ca69da138ee1260e25881425b6e94de09d8640f0ed2ad17f9cfee38b62ebaef30d6ed408546e1990c8d35f906cccc5dcf7 40 - snefru256 1909e6a91b71c4df359f9b8f04ff0c118458db425434e93e2ea01ad7f87af6f2 41 - snefru 1909e6a91b71c4df359f9b8f04ff0c118458db425434e93e2ea01ad7f87af6f2 42 - md2 af498550d2f33be614ce6804ffcc8c7d Hashes Posibilities 1 - whirlpool 1.34078079299E+154 2 - sha512 1.34078079299E+154 3 - salsa20 1.34078079299E+154 4 - salsa10 1.34078079299E+154 5 - sha384 3.94020061964E+115 6 - ripemd320 2.13598703592E+96 7 - gost 1.15792089237E+77 8 - haval256,4 1.15792089237E+77 9 - sha256 1.15792089237E+77 10 - haval256,3 1.15792089237E+77 11 - snefru 1.15792089237E+77 12 - haval256,5 1.15792089237E+77 13 - snefru256 1.15792089237E+77 14 - ripemd256 1.15792089237E+77 15 - sha224 2.69599466672E+67 16 - haval224,3 2.69599466672E+67 17 - haval224,5 2.69599466672E+67 18 - haval224,4 2.69599466672E+67 19 - tiger192,3 6.27710173539E+57 20 - tiger192,4 6.27710173539E+57 21 - haval192,3 6.27710173539E+57 22 - haval192,4 6.27710173539E+57 23 - haval192,5 6.27710173539E+57 24 - haval160,5 1.46150163733E+48 25 - tiger160,4 1.46150163733E+48 26 - ripemd160 1.46150163733E+48 27 - haval160,3 1.46150163733E+48 28 - sha1 1.46150163733E+48 29 - tiger160,3 1.46150163733E+48 30 - haval160,4 1.46150163733E+48 31 - tiger128,4 3.40282366921E+38 32 - haval128,3 3.40282366921E+38 33 - md5 3.40282366921E+38 34 - md4 3.40282366921E+38 35 - haval128,5 3.40282366921E+38 36 - haval128,4 3.40282366921E+38 37 - tiger128,3 3.40282366921E+38 38 - md2 3.40282366921E+38 39 - ripemd128 3.40282366921E+38 40 - adler32 4294967296 41 - crc32b 4294967296 42 - crc32 4294967296 Hashes Average Rank 1 - salsa10 2 - salsa20 3 - ripemd256 4 - tiger192,3 5 - ripemd320 6 - sha256 7 - haval224,3 8 - sha1 9 - haval256,4 10 - tiger192,4 11 - haval256,3 12 - md4 13 - md5 14 - sha224 15 - tiger160,4 16 - haval192,3 17 - sha512 18 - tiger160,3 19 - whirlpool 20 - sha384 21 - crc32 22 - crc32b 23 - tiger128,3 24 - gost 25 - haval256,5 26 - haval224,4 27 - adler32 28 - tiger128,4 29 - haval160,3 30 - ripemd160 31 - haval224,5 32 - ripemd128 33 - snefru 34 - haval192,4 35 - snefru256 36 - haval160,5 37 - haval192,5 38 - haval160,4 39 - haval128,3 40 - haval128,4 41 - haval128,5 42 - md2 Entire page took 23.759114027 seconds </code></pre> </div>

如何使用该行中的用户名生成的哈希来填充mysql中的整个列

<div class="post-text" itemprop="text"> <p>The query I have so far is :</p> <pre><code>create table users_csv_import ( username varchar(255), reg_link varchar(255) ); insert into users_csv_import (username, reg_link) values ('kns2184', 'NULL'); insert into users_csv_import (username, reg_link) values ('kns2185', 'NULL'); insert into users_csv_import (username, reg_link) values ('kns2186', 'NULL'); insert into users_csv_import (username, reg_link) values ('kns2187', 'NULL'); insert into users_csv_import (username, reg_link) values ('kns2188', 'NULL'); update users_csv_import set reg_link = md5(username in row should go here?) where reg_link='NULL'; </code></pre> <p>So what I would like to do is for every row generate md5 hash from username in that row. I do not want to use a php loop, I would like to do this through mysql because I assume it will be much faster then something like an array of generated hashes via php. </p> <p><a href="http://sqlfiddle.com/#!2/da389/1" rel="nofollow">http://sqlfiddle.com/#!2/da389/1</a></p> </div>

用于对数组进行指纹识别的最快方法(从数据数组计算唯一哈希)

<div class="post-text" itemprop="text"> <p>I am using a lot of caching and buffering of API calls in my WWW Framework and one of the things that I end up using all around is 'fingerprinting' data in order to match cache filenames as well as detecting API calls that have already been made.</p> <p>A lot of data is moved in arrays, like GET, POST and so on. As a result the uniqueness of an API call depends on the data.</p> <p>As a result I need to fingerprint this information. To do it requires generating a 'fingerprint' from the data array as well and hashing it into a string that I can store and compare against.</p> <p>For array serialization there is serialize() and json_encode() in PHP. After various benchmarks I consider json_encode() the faster method for serializing an array and am quite happy with it.</p> <p>For hashing there is md5() and sha1() functions, of which md5() is faster according to my benchmarks.</p> <p>So my current fingerprint algorithm is:</p> <pre><code>$fingerprint=md5(json_encode($array)); </code></pre> <p>But I am having doubts whether this is the 'fastest possible' method for fingerprinting an array in PHP. I have tried Google and StackOverflow and have not found good alternatives though. Am I on a right track or do I need to do something different?</p> </div>

Go SHA-256哈希与Java SHA-256哈希不同

<div class="post-text" itemprop="text"> <p>If I generate the SHA-256 hash in the language "GO", I get a different byte-Array compared to the Java equivalent.</p> <p>This is the GO version:</p> <pre><code>fmt.Println(getSha256([]byte("5nonce=5"))) </code></pre> <p>The resulting array looks like:</p> <pre><code>41 79 186 235 199 123 95 226 16 59 51 161 112 245 192 50 21 66 180 250 179 109 153 18 233 148 16 237 156 69 163 150] </code></pre> <p>This one should do the same in Java code:</p> <pre><code>MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update("5nonce=5".getBytes()); byte[] digest = md.digest(); </code></pre> <p>But results in this byte array</p> <pre><code>[41, 79, -70, -21, -57, 123, 95, -30, 16, 59, 51, -95, 112, -11, -64, 50, 21, 66, -76, -6, -77, 109, -103, 18, -23, -108, 16, -19, -100, 69, -93, -106] </code></pre> <p>Why are they different? How do I need to change the java version to work exactly like the Go version?</p> </div>

lua可以计算字符串的hash值么?

小弟在用lua写个脚本需要根据字符串的哈希值进行分组,找了半天也没找到相关的库函数,请问使用lua怎么能得出字符串的hash值呢?

PHP - 无论如何在PHP中加密/解密哈希? [关闭]

<div class="post-text" itemprop="text"> <p>I'm interested to encrypt/decrpyt hash in PHP.</p> <p>But as I know hash can be encoding only with md5, sha1, sha256.</p> <p>However, is it possible to make encrypt/decrpyt in PHP by another hash like ripemd160, haval256,5 or ripemd256?</p> <p>Thank</p> </div>

Tinyurl 中url的生成策略

tinyurl可以将一长串的url转换为相当短的url,比如 http://preview.tinyurl.com/2wqbcs。 我对 2wqbcs 这种形式的串比较感兴趣,感觉类似UUID或MD5这样的哈希算法所产生的,youtube的视频网址也有类似这样的串 http://www.youtube.com/watch?v=9SBB14vu8jM 个人猜测是这几种可能之一: 1.产生一个大的随机数,将这个数字转换为以数字和字母所表示的字符串。感觉这个可能性比较大,类似UUID这样,只要整数值足够大,重复几率很小。 2.一种哈希函数,输入产生特定输出。对于tinyurl,它的长度和源url长度没有关联,感觉不像。 3.一种加密算法,数据是可逆的。 有对这个了解的朋友,能介绍一下么?

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

程序员必知的 89 个操作系统核心概念

操作系统(Operating System,OS):是管理计算机硬件与软件资源的系统软件,同时也是计算机系统的内核与基石。操作系统需要处理管理与配置内存、决定系统资源供需的优先次序、控制输入与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。 shell:它是一个程序,可从键盘获取命令并将其提供给操作系统以执行。 在过去,它是类似 Unix 的系统上...

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

立即提问
相关内容推荐