Ok so here is how We do passwords.
note We did change what we salt by.
<?
$PASSWORD = $_GET["password"];
$ranNUM = rand(965824, 957873488423748423486483);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
for ($i = 1; $i <= $_GET['num']; $i++) {
$PASSWORD = md5($PASSWORD);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', FALSE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = md5($PASSWORD);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', FALSE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = md5($PASSWORD);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', FALSE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
$PASSWORD = hash('sha512', $PASSWORD.$ranNUM.'MONKEY MONEY sad happy 7ab27t8g2hjq8tt 2g y8t 82 t2g edb t7e2gqjcb t8egsjc byut87qebcjn 87ctyeqcb t78ye jscyt8ique bcg781eghjs btgq78 cbqjg78pqdgj d t87dqgjh bxauy fpqdgs,q vayupf d', TRUE);
print $PASSWORD;
print "<br>";
}
//print $PASSWORD;
?>
What we do is we send a num say 7 along with the password then we run the encryption 7 times
along with the random number for that user (which is saved in another DB) NOT ON THE SAME SERVER
we then have what the password should be.
What do you think is this over kill?
for e.g 123 running twice would get
íaªyå`ˆsœA²„†N¸jø¦žÃïªd*hÂ?‘\e½s&žÉ:Ñl6DïƒÀ`ß,¢‹HÎÌ(üBìð6
to make this even safer you could have random paragraphs for each one.
You would need to have it saved somewhere, but would be great if you could just scan a google or bing or any site, and get a random sentence from there site.
Please tell me your thoughts.
It's an overkill, and I'm not sure it's theoretically sound.
One sound method of making your (salted) password a pain to bruteforce is RSA's PBKDF2.
Here's a PBKDF2 PHP implementation.
You may also be interested in Blowcrypt (similar intent, but using the blowfish algorithms) and Scrypt (a nasty little fellow that can be told how much memory you wish the attacker to waste over bruteforcing your password)
Related
I have two files - FileA and FileB. FileA will be changed. FileB contains the new values. FileB has 3 fields. The first two fields will be compared with FileA's first two fields. If the fields match, Field3 should be changed. The code below is working in this manner: "If the two values match, change field3 and print the line. If there is no match, next." The behavior I want is, "If there is no match, print the line unchanged." The "else" part of the code is not working and I've tried so many variations.
awk -F'\t' -v OFS='\t' '
# first, read in data from file B
NR == FNR { values[$1 FS $2] = $3; next }
# then, output modified lines from matching lines in file A
($1 FS $2) in values { $3 = values[$1 FS $2]; print } else { print $0 }
' fileB fileA
FileA
PROVDSRJ02.RD.RI ae0.0 16
PROVDSRJ02.RD.RI ae1.1 1000
PROVDSRJ02.RD.RI ae2.0 5000
PROVDSRJ02.RD.RI ae3.0 5000
ASHBBBRJ01.RD.AS ae39.0 16
ASHBBPRJ01.RD.AS ae2.0 16
ASHBBPRJ02.RD.AS ae1.0 16
ASHBBPRJ02.RD.AS ae2.0 16
ASHBBBRJ01.RD.AS ae0.0 16
ASHBBBRJ01.RD.AS ae11.0 16
FileB
ASHBBBRJ01.RD.AS ae10.0 524
ASHBBBRJ01.RD.AS ae11.0 235
ASHBBBRJ01.RD.AS ae39.0 2096
ASHBBBRJ01.RD.AS ae6.0 183
ASHBBBRJ01.RD.AS ae7.0 1141
ASHBBBRJ02.RD.AS ae11.0 88
ASHBBBRJ02.RD.AS ae13.0 333
ASHBBBRJ02.RD.AS ae20.0 374
ASHBBBRJ02.RD.AS ae9.0 1885
Desired Output (** indicate changed lines and should not be included in code)
PROVDSRJ02.RD.RI ae0.0 16
PROVDSRJ02.RD.RI ae1.1 1000
PROVDSRJ02.RD.RI ae2.0 5000
PROVDSRJ02.RD.RI ae3.0 5000
**ASHBBBRJ01.RD.AS ae39.0 2096**
ASHBBPRJ01.RD.AS ae2.0 16
ASHBBPRJ02.RD.AS ae1.0 16
ASHBBPRJ02.RD.AS ae2.0 16
ASHBBBRJ01.RD.AS ae0.0 16
**ASHBBBRJ01.RD.AS ae11.0 235**
Your syntax is off. Check the tag info for some learning resources.
In any case, you don't need an else as such. You can conditionally set $3 to the new value (as you already are doing), and then always print the line (which may have been modified or not).
Here we use the shortcut 1 to always print the line. 1 is an always-true pattern that invokes the default action, which is to print the current line. If that doesn't make sense now, it will soon.
$ awk 'BEGIN {FS=OFS="\t"}
NR == FNR {values[$1 FS $2] = $3; next}
($1 FS $2) in values {$3 = values[$1 FS $2]}1' fileB fileA
PROVDSRJ02.RD.RI ae0.0 16
PROVDSRJ02.RD.RI ae1.1 1000
PROVDSRJ02.RD.RI ae2.0 5000
PROVDSRJ02.RD.RI ae3.0 5000
ASHBBBRJ01.RD.AS ae39.0 2096
ASHBBPRJ01.RD.AS ae2.0 16
ASHBBPRJ02.RD.AS ae1.0 16
ASHBBPRJ02.RD.AS ae2.0 16
ASHBBBRJ01.RD.AS ae0.0 16
ASHBBBRJ01.RD.AS ae11.0 235
I have an audio program that makes a call to AudioConverterFillComplexBuffer with the following code:
OSStatus error = AudioConverterFillComplexBuffer(recorderObj->audioConverter,
MyAudioConverterCallback,
(__bridge void *)playerLocal,
&ioOutputDataPackets,
convertedData,
&streamDesc);
When this code runs on 10.6-10.11, it works fine. When the code runs on 10.12, it crashes with the following message
Crashed Thread: 16 com.apple.audio.IOThread.client
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
The call stack ends in CrashIfClientProvidedBogusAudioBufferList.
Most articles, documentation and mailing lists would say that I have a bad output buffer but for the life of me, I cannot tell what I would be doing wrong but still have my code work on all versions of MacOS but the latest. Here is how I am setting up the buffer:
AudioBufferList *convertedData = (AudioBufferList*)malloc(sizeof(AudioBufferList) * 2);
convertedData->mNumberBuffers = 1;
convertedData->mBuffers[0].mNumberChannels = 2;
convertedData->mBuffers[0].mDataByteSize = 64 * 1024;
convertedData->mBuffers[0].mData = (UInt8 *)malloc(sizeof(UInt8) * 64 * 1024);
Here is the full stack at the point of the crash
Thread 16 Crashed:: com.apple.audio.IOThread.client
0 com.apple.audio.toolbox.AudioToolbox 0x00007fff89b9a330 CADebuggerStop() + 4
1 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a21e71 CrashIfClientProvidedBogusAudioBufferList + 97
2 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f710 AudioConverterChain::CallInputProc(unsigned int) + 646
3 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f386 AudioConverterChain::FillBufferFromInputProc(unsigned int*, CABufferList*) + 130
4 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2ee BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 178
5 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f1b2 CBRConverter::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 106
6 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
7 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2c3 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 135
8 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a9369b Resampler2Wrapper::RenderOutput(CABufferList*, unsigned int, unsigned int&) + 183
9 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
10 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f2c3 BufferedAudioConverter::GetInputBytes(unsigned int, unsigned int&, CABufferList const*&) + 135
11 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2f1b2 CBRConverter::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 106
12 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
13 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2253f AudioConverterChain::RenderOutput(CABufferList*, unsigned int, unsigned int&, AudioStreamPacketDescription*) + 99
14 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a2225d BufferedAudioConverter::FillBuffer(unsigned int&, AudioBufferList&, AudioStreamPacketDescription*) + 281
15 com.apple.audio.toolbox.AudioToolbox 0x00007fff89a21d2f AudioConverterFillComplexBuffer + 282
16 com.pc-intercom.Intercom 0x0000000107a52803 0x107a4a000 + 34819
17 com.apple.audio.units.Components 0x000000010a38c97c AUHAL::AUIOProc(unsigned int, AudioTimeStamp const*, AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*, void*) + 2324
18 com.apple.audio.CoreAudio 0x00007fff8a71f951 HALC_ProxyIOContext::IOWorkLoop() + 4369
19 com.apple.audio.CoreAudio 0x00007fff8a71e667 HALC_ProxyIOContext::IOThreadEntry(void*) + 131
20 com.apple.audio.CoreAudio 0x00007fff8a71e38b HALB_IOThread::Entry(void*) + 75
21 libsystem_pthread.dylib 0x0000000108134aab _pthread_body + 180
22 libsystem_pthread.dylib 0x00000001081349f7 _pthread_start + 286
23 libsystem_pthread.dylib 0x0000000108134221 thread_start + 13
If anyone has any suggestions on how I can debug this issue, I would greatly appreciate the help.
In MyAudioConverterCallback, ioDataPacketCount is supposed to return frames for LPCM (I guess packets are frames for uncompressed audio), so set it to:
*ioDataPacketCount = recorderObj->inputBuffer->mBuffers[0].mDataByteSize/recorderObj->streamFormat.mBytesPerFrame;
Pass a NULL AudioStreamPacketDescription to AudioConverterFillComplexBuffer instead of an array of 1 (this was causing crashes for me on 10.11). Your destination format is LPCM, so packet descriptions are unnecessary because your "packets" are all the same size.
Similarly, your source format is LPCM too, so you can remove the code that returns packet descriptions in MyAudioConverterCallback - it's also wrong.
On my machine, I get non-interleaved stereo for streamFormat which means MyAudioConverterCallback has to fill out ioData->mBuffers[1] too.
When setting up your convertedData AudioBufferList, sizePerPacket was using the source format packet size instead of the destination packet size. It should be:
sizePerPacket = mOutputFormat.mBytesPerPacket;
And finally, even when it's not crashing, this code can't be right because you're recording (say) 512 frames from the microphone, then asking the audio converter to convert 16384 - that's going to give you audio glitches.
The callback is given an audio buffer list pointed to by ioData. This
buffer list may refer to existing buffers owned and allocated by the
audio converter, in which case the callback may use them and copy
input audio data into them. However, the buffer list may also be
empty (mDataByteSize == 0 and/or mData == NULL), in which case the
callback must provide its own buffers. The callback manipulates the
members of ioData to point to one or more buffers of audio data
(multiple buffers are used with non-interleaved PCM data). The
callback is responsible for not freeing or altering this buffer until
it is called again.
In the AudioConverterComplexInputDataProc callback, When I try to return a ioData with it's mBuffers[0].mData == NULL, I got this crash.
I have a tab-separated file containing a series of lemmas with associated scores.
The file contains 5 columns, the first column is the lemma and the third is the one that contains the score. What I need to do is print the line as it is, when lemma is not repeated and print the line with the highest score when lemma is repeated.
IN
Lemma --- Score --- ---
cserép 06a 55 6 bueno
darázs 05 38 1 bueno
dél 06a 34 1 bueno
dér 06a 29 1 bueno
díj 05 14 89 malo
díj 06a 2 101 malo
díj 06b 2 101 malo
díj 07 90 13 bueno
díj 08a 2 101 malo
díj 08b 2 101 malo
egér 06a 66 5 bueno
fonal 05 12 1 bueno
fonal 07 52 4 bueno
Desired output
Lemma --- Score --- ---
cserép 06a 55 6 bueno
darázs 05 38 1 bueno
dél 06a 34 1 bueno
dér 06a 29 1 bueno
díj 07 90 13 bueno
egér 06a 66 5 bueno
fonal 07 52 4 malo
What I have done. But it only works when the lemma is repeated once.
BEGIN {
OFS=FS="\t";
flag="";
}
{
id=$1;
if (id != flag)
{
if (line != "")
{
sub("^;","",line);
z=split(line,A,";");
if ((A[3] > A[8]) && (A[8] != ""))
{
print A[1]"\t"A[2]"\t"A[3]"\t"A[4]"\t"A[5];
}
else if ((A[8] > A[3]) && (A[8] != ""))
{
print A[6]"\t"A[7]"\t"A[8]"\t"A[9]"\t"A[10]
}
else
{
print A[1]"\t"A[2]"\t"A[3]"\t"A[4]"\t"A[5];
}
}
delete line;
flag=id;
}
line[$1]=line[$1]";"$2";"$3";"$4";"$5;
}
END {
line=line ";"$1";"$2";"$3";"$4";"$5
sub("^;","",line);
z=split(line,A,";");
if ((A[3] > A[8]) && (A[8] != ""))
{
print A[1]"\t"A[2]"\t"A[3]"\t"A[4]"\t"A[5];
}
else if ((A[8] > A[3]) && (A[8] != ""))
{
print A[6]"\t"A[7]"\t"A[8]"\t"A[9]"\t"A[10]
}
else
{
print A[1]"\t"A[2]"\t"A[3]"\t"A[4]"\t"A[5]
}
}
This one doesn't require the file to be sorted by lemma, but, it keeps all the lines to be printed in memory (one for each lemma) so may not be appropriate for a file with millions of different lemmas.
It also does not respect the order of the original file.
Finally, it assumes that all scores are non-negative!
$ cat lemma.awk
BEGIN { FS = OFS = "\t" }
NR == 1 { print }
NR > 1 {
if ($3 > score[$1]) {
score[$1] = $3
line[$1] = $0
}
}
END { for (lemma in line) print line[lemma] }
$ awk -f lemma.awk lemma.txt
Lemma --- Score --- ---
cserép 06a 55 6 bueno
díj 07 90 13 bueno
fonal 07 52 4 bueno
darázs 05 38 1 bueno
egér 06a 66 5 bueno
dél 06a 34 1 bueno
dér 06a 29 1 bueno
Tested with gnu awk:
prevLemma != $1 {
if( prevLemma ) {
print line;
}
prevLemma = $1;
prevScore = $3;
line = $0;
}
prevLemma == $1 { if( prevScore < $3 ) {
prevScore = $3;
line = $0;
}
}
END { print line;}
assumption is: the file is sorted by lemma
when the lemma changes (or at the very beginning when the var is empty) the lemma, score and line are saved
when the lemma changes (or in the END), the line for the previous lemma is printed
when the current line belongs to the same lemma and has a higher score the values are saved again
$ cat tst.awk
$1 != prev { printf "%s", maxLine; maxLine=""; max=$3; prev=$1 }
$3 >= max { max=$3; maxLine=$0 ORS }
END { printf "%s", maxLine }
$ awk -f tst.awk file
Lemma --- Score --- ---
cserép 06a 55 6 bueno
darázs 05 38 1 bueno
dél 06a 34 1 bueno
dér 06a 29 1 bueno
díj 07 90 13 bueno
egér 06a 66 5 bueno
fonal 07 52 4 bueno
Use a script:
if ($1 != $5) print $0
else
{
score($NR) = $3
print $0
}
Actually , this might be better done with perl.
In my cocoa application, I am using WebView to load my URL. For my requirement, I will reload the URL for every 10 minutes. But sometimes, the app got crashed when I am trying to reload. I am using the below code to load the URL in webview.
sample.h
#import <WebKit/WebKit.h>
#property(nonatomic,retain) IBOutlet WebView *webview;
Sample.m
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:#"www.dummyurl.com"]];
[self->webview.mainFrame loadRequest:request];
StackTrace:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fff56efeff8
VM Regions Near 0x7fff56efeff8:
MALLOC_TINY 00007f9e7b000000-00007f9e7b100000 [ 1024K] rw-/rwx SM=ZER
--> STACK GUARD 00007fff536ff000-00007fff56eff000 [ 56.0M] ---/rwx SM=NUL stack guard for thread 0
Stack 00007fff56eff000-00007fff576ff000 [ 8192K] rw-/rwx SM=COW thread 0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.WebCore 0x00007fff90238264 WebCore::RenderObject::containingBlock() const + 4
1 com.apple.WebCore 0x00007fff9036cdaf WebCore::RenderBlock::computeBlockPreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 63
2 com.apple.WebCore 0x00007fff90d0524a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 58
3 com.apple.WebCore 0x00007fff9047eaab WebCore::RenderBox::computeIntrinsicLogicalWidthUsing(WebCore::Length, WebCore::LayoutUnit, WebCore::LayoutUnit) const + 187
4 com.apple.WebCore 0x00007fff9033f8f4 WebCore::RenderBox::computeReplacedLogicalWidthUsing(WebCore::Length) const + 212
5 com.apple.WebCore 0x00007fff9033f707 WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(WebCore::LayoutUnit, WebCore::ShouldComputePreferred) const + 215
6 com.apple.WebCore 0x00007fff9033f572 WebCore::RenderReplaced::computeReplacedLogicalWidth(WebCore::ShouldComputePreferred) const + 1074
7 com.apple.WebCore 0x00007fff9033fcfb WebCore::RenderReplaced::computePreferredLogicalWidths() + 139
8 com.apple.WebCore 0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
9 com.apple.WebCore 0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
10 com.apple.WebCore 0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
11 com.apple.WebCore 0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
12 com.apple.WebCore 0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
13 com.apple.WebCore 0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
14 com.apple.WebCore 0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
15 com.apple.WebCore 0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
16 com.apple.WebCore 0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
17 com.apple.WebCore 0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
18 com.apple.WebCore 0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
19 com.apple.WebCore 0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
20 com.apple.WebCore 0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
21 com.apple.WebCore 0x00007fff9036d07c WebCore::RenderBlock::computeBlockPreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 780
22 com.apple.WebCore 0x00007fff90d0524a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 58
23 com.apple.WebCore 0x00007fff9047eaab WebCore::RenderBox::computeIntrinsicLogicalWidthUsing(WebCore::Length, WebCore::LayoutUnit, WebCore::LayoutUnit) const + 187
24 com.apple.WebCore 0x00007fff9033f8f4 WebCore::RenderBox::computeReplacedLogicalWidthUsing(WebCore::Length) const + 212
25 com.apple.WebCore 0x00007fff9033f707 WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(WebCore::LayoutUnit, WebCore::ShouldComputePreferred) const + 215
26 com.apple.WebCore 0x00007fff9033f572 WebCore::RenderReplaced::computeReplacedLogicalWidth(WebCore::ShouldComputePreferred) const + 1074
27 com.apple.WebCore 0x00007fff9033fcfb WebCore::RenderReplaced::computePreferredLogicalWidths() + 139
28 com.apple.WebCore 0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
29 com.apple.WebCore 0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
Anyone please provide the solution to resolve this issue?
PS : I am using ARC in my project.
i suggest you set exception breakpoint to find exact problem with your code , but i hope your problem is Released object
i think your UIWebView or Url become to nil.
please use strong property for your objects.
can you show a little of your code ?
do you use custom webview or custom webkit ?
I need to convert NSString in unicode to NSString in ASCII changing all local characters:
Ą to A,
Ś to S,
Ó to O,
ü to u,
And so on...
What is the simplest way to do it?
-[NSString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES].
All of the examples you gave are handled as you want. Looks like characters with no obvious analog, such as ☃, go to '?'.
NSString *unicode = #"Chào mừng đến với Việt Nam.";
NSString *standard = [unicode stringByReplacingOccurrencesOfString:#"đ" withString:#"d"];
standard = [standard stringByReplacingOccurrencesOfString:#"Đ" withString:#"D"];
NSData *decode = [standard dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *ansi = [[NSString alloc] initWithData:decode encoding:NSASCIIStringEncoding];
NSLog(#"ANSI: %#", ansi);
Ken answer will replace "æ" with "ae" and "ß" with "s", but won't replace ligatures œ, ij, ff, fi, fl, ffi, ffl, ſt, st, ...
An improved solution is to first insert additional lines of mapping to handle everything fine:
string = [string stringByReplacingOccurrencesOfString:#"Œ" withString:#"OE"];
string = [string stringByReplacingOccurrencesOfString:#"œ" withString:#"oe"];
string = [string stringByReplacingOccurrencesOfString:#"Đ" withString:#"D"];
string = [string stringByReplacingOccurrencesOfString:#"đ" withString:#"d"];
string = [string precomposedStringWithCompatibilityMapping];
NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *newString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
Objective C's NSASCIIEncoding only supports upto 127 , the character set you are looking for are beyond 127 in ASCII table.
NSASCIIStringEncoding
Strict 7-bit ASCII encoding within 8-bit chars; ASCII values 0…127 only.
Available in Mac OS X v10.0 and later.
Declared in NSString.h.
NSData *data = [decode dataUsingEncoding:[NSString defaultCStringEncoding]];
decode = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSUTF8StringEncoding, and [NSSring UTF8String] was not working for me under Xcode 12.2
Here is a my custom NSString Category which works for all ASCII values 0..255 in objective c
Header-fle
#import <Cocoa/Cocoa.h>
#interface NSString (ASCIIEncode)
- (const char*)ASCIIEncode;
#end
Implementation
#import "NSString+ASCIIEncode.h"
#implementation NSString (ASCIIEncode)
- (const char*)ASCIIEncode {
static char output[1024];
// https://tools.piex.at/ascii-tabelle/
// https://www.ionos.de/digitalguide/server/knowhow/ascii-american-standard-code-for-information-interchange/
NSMutableArray *ascii = [NSMutableArray new];
// Hex
// 000 Dez Hex
[ascii addObject:#"\0"]; // 000 000 NUL
[ascii addObject:#( 1)]; // 001 001 SOH
[ascii addObject:#( 2)]; // 002 002 STX
[ascii addObject:#( 3)]; // 003 003 ETX
[ascii addObject:#( 4)]; // 004 004 EOT
[ascii addObject:#( 5)]; // 005 005 ENQ
[ascii addObject:#( 6)]; // 006 006 ACK
[ascii addObject:#"\a"]; // 007 007 BEL
[ascii addObject:#"\b"]; // 008 008 BS
[ascii addObject:#( 9)]; // 009 009 TAB
[ascii addObject:#"\n"]; // 010 00A LF
[ascii addObject:#(11)]; // 011 00B VT
[ascii addObject:#(12)]; // 012 00C FF
[ascii addObject:#"\r"]; // 013 00D CR
[ascii addObject:#(14)]; // 014 00E SO
[ascii addObject:#(15)]; // 015 00F NAK
// 010
[ascii addObject:#(16)]; // 016 010 DLE
[ascii addObject:#(17)]; // 017 011 DC1
[ascii addObject:#(18)]; // 018 012 DC2
[ascii addObject:#(19)]; // 019 013 DC3
[ascii addObject:#(20)]; // 020 014 DC4
[ascii addObject:#(21)]; // 021 015 NAK
[ascii addObject:#(22)]; // 022 016 SYN
[ascii addObject:#(23)]; // 023 017 ETB
[ascii addObject:#(24)]; // 024 018 CAN
[ascii addObject:#(25)]; // 025 019 EM
[ascii addObject:#(26)]; // 026 01A SUB
[ascii addObject:#(27)]; // 027 01B ESC
[ascii addObject:#(28)]; // 028 01C FS
[ascii addObject:#(29)]; // 029 01D GS
[ascii addObject:#(30)]; // 030 01E RS
[ascii addObject:#(31)]; // 031 01F US
// 020
[ascii addObject:#" "]; // 032 020 Space
[ascii addObject:#"!"]; // 033 021
[ascii addObject:#"\""]; // 034 022
[ascii addObject:#"#"]; // 035 023
[ascii addObject:#"$"]; // 036 024
[ascii addObject:#"%"]; // 037 025
[ascii addObject:#"&"]; // 038 026
[ascii addObject:#"'"]; // 039 027
[ascii addObject:#"("]; // 040 028
[ascii addObject:#")"]; // 041 029
[ascii addObject:#"*"]; // 042 02A
[ascii addObject:#"+"]; // 043 02B
[ascii addObject:#","]; // 044 02C
[ascii addObject:#"-"]; // 045 02D
[ascii addObject:#"."]; // 046 02E
[ascii addObject:#"/"]; // 047 02F
// 030
[ascii addObject:#"0"]; // 048 030
[ascii addObject:#"1"]; // 049 031
[ascii addObject:#"2"]; // 050 032
[ascii addObject:#"3"]; // 051 033
[ascii addObject:#"4"]; // 052 034
[ascii addObject:#"5"]; // 053 035
[ascii addObject:#"6"]; // 054 036
[ascii addObject:#"7"]; // 055 037
[ascii addObject:#"8"]; // 056 038
[ascii addObject:#"9"]; // 057 039
[ascii addObject:#":"]; // 058 03A
[ascii addObject:#";"]; // 059 03B
[ascii addObject:#"<"]; // 060 03C
[ascii addObject:#"="]; // 061 03D
[ascii addObject:#">"]; // 062 03E
[ascii addObject:#"?"]; // 063 03F
// 040
[ascii addObject:#"#"]; // 064 040
[ascii addObject:#"A"]; // 065 041
[ascii addObject:#"B"]; // 066 042
[ascii addObject:#"C"]; // 067 043
[ascii addObject:#"D"]; // 068 044
[ascii addObject:#"E"]; // 069 045
[ascii addObject:#"F"]; // 070 046
[ascii addObject:#"G"]; // 071 047
[ascii addObject:#"H"]; // 072 048
[ascii addObject:#"I"]; // 073 049
[ascii addObject:#"J"]; // 074 04A
[ascii addObject:#"K"]; // 075 04B
[ascii addObject:#"L"]; // 076 04C
[ascii addObject:#"M"]; // 077 04D
[ascii addObject:#"N"]; // 078 04E
[ascii addObject:#"O"]; // 079 04F
// 050
[ascii addObject:#"P"]; // 080 050
[ascii addObject:#"Q"]; // 081 051
[ascii addObject:#"R"]; // 082 052
[ascii addObject:#"S"]; // 083 053
[ascii addObject:#"T"]; // 084 054
[ascii addObject:#"U"]; // 085 055
[ascii addObject:#"V"]; // 086 056
[ascii addObject:#"W"]; // 087 057
[ascii addObject:#"X"]; // 088 058
[ascii addObject:#"Y"]; // 089 059
[ascii addObject:#"Z"]; // 090 05A
[ascii addObject:#"["]; // 091 05B
[ascii addObject:#"\\"]; // 092 05C
[ascii addObject:#"]"]; // 093 05D
[ascii addObject:#"^"]; // 094 05E
[ascii addObject:#"_"]; // 095 05F
// 060
[ascii addObject:#"`"]; // 096 060
[ascii addObject:#"a"]; // 097 061
[ascii addObject:#"b"]; // 098 062
[ascii addObject:#"c"]; // 099 063
[ascii addObject:#"d"]; // 100 064
[ascii addObject:#"e"]; // 101 065
[ascii addObject:#"f"]; // 102 066
[ascii addObject:#"g"]; // 103 067
[ascii addObject:#"h"]; // 104 068
[ascii addObject:#"i"]; // 105 069
[ascii addObject:#"j"]; // 106 06A
[ascii addObject:#"k"]; // 107 06B
[ascii addObject:#"l"]; // 108 06C
[ascii addObject:#"m"]; // 109 06D
[ascii addObject:#"n"]; // 110 06E
[ascii addObject:#"o"]; // 111 06F
// 070
[ascii addObject:#"p"]; // 112 070
[ascii addObject:#"q"]; // 113 071
[ascii addObject:#"r"]; // 114 072
[ascii addObject:#"s"]; // 115 073
[ascii addObject:#"t"]; // 116 074
[ascii addObject:#"u"]; // 117 075
[ascii addObject:#"v"]; // 118 076
[ascii addObject:#"w"]; // 119 077
[ascii addObject:#"x"]; // 120 078
[ascii addObject:#"y"]; // 121 079
[ascii addObject:#"z"]; // 122 07A
[ascii addObject:#"{"]; // 123 07B
[ascii addObject:#"|"]; // 124 07C
[ascii addObject:#"}"]; // 125 07D
[ascii addObject:#"~"]; // 126 07E
[ascii addObject:#(127)];// 127 07F DEL
// 080
[ascii addObject:#"€"]; // 128 080
[ascii addObject:#(129)];// 129 081
[ascii addObject:#"‚"]; // 130 082
[ascii addObject:#"ƒ"]; // 131 083
[ascii addObject:#"„"]; // 132 084
[ascii addObject:#"…"]; // 133 085
[ascii addObject:#"†"]; // 134 086
[ascii addObject:#"‡"]; // 135 087
[ascii addObject:#"ˆ"]; // 136 088
[ascii addObject:#"‰"]; // 137 089
[ascii addObject:#"Š"]; // 138 08A
[ascii addObject:#"‹"]; // 139 08B
[ascii addObject:#"Œ"]; // 140 08C
[ascii addObject:#(141)];// 141 08D
[ascii addObject:#"Ž"]; // 142 08E
[ascii addObject:#(143)]; // 143 08F
// 090
[ascii addObject:#(144)];// 144 090
[ascii addObject:#"‘"]; // 145 091
[ascii addObject:#"’"]; // 146 092
[ascii addObject:#"“"]; // 147 093
[ascii addObject:#"”"]; // 148 094
[ascii addObject:#"•"]; // 149 095
[ascii addObject:#"–"]; // 150 096
[ascii addObject:#"—"]; // 151 097
[ascii addObject:#"˜"]; // 152 098
[ascii addObject:#"™"]; // 153 099
[ascii addObject:#"š"]; // 154 09A
[ascii addObject:#"›"]; // 155 09B
[ascii addObject:#"œ"]; // 156 09C
[ascii addObject:#(157)];// 157 09D
[ascii addObject:#"ž"]; // 158 09E
[ascii addObject:#"Ÿ"]; // 159 09F
// 0A0
[ascii addObject:#(160)];// 160 0A0
[ascii addObject:#"¡"]; // 161 0A1
[ascii addObject:#"¢"]; // 162 0A2
[ascii addObject:#"£"]; // 163 0A3
[ascii addObject:#"¤"]; // 164 0A4
[ascii addObject:#"¥"]; // 165 0A5
[ascii addObject:#"¦"]; // 166 0A6
[ascii addObject:#"§"]; // 167 0A7
[ascii addObject:#"¨"]; // 168 0A8
[ascii addObject:#"©"]; // 169 0A9
[ascii addObject:#"ª"]; // 170 0AA
[ascii addObject:#"«"]; // 171 0AB
[ascii addObject:#"¬"]; // 172 0AC
[ascii addObject:#(173)];// 173 0AD
[ascii addObject:#"®"]; // 174 0AE
[ascii addObject:#"¯"]; // 175 0AF
// 0B0
[ascii addObject:#"°"]; // 176 0B0
[ascii addObject:#"±"]; // 177 0B1
[ascii addObject:#"²"]; // 178 0B2
[ascii addObject:#"³"]; // 179 0B3
[ascii addObject:#"´"]; // 180 0B4
[ascii addObject:#"µ"]; // 181 0B5
[ascii addObject:#"¶"]; // 182 0B6
[ascii addObject:#"·"]; // 183 0B7
[ascii addObject:#"¸"]; // 184 0B8
[ascii addObject:#"¹"]; // 185 0B9
[ascii addObject:#"º"]; // 186 0BA
[ascii addObject:#"»"]; // 187 0BB
[ascii addObject:#"¼"]; // 188 0BC
[ascii addObject:#"½"]; // 189 0BD
[ascii addObject:#"¾"]; // 190 0BE
[ascii addObject:#"¿"]; // 191 0BF
// 0C0
[ascii addObject:#"À"]; // 192 0C0
[ascii addObject:#"Á"]; // 193 0C1
[ascii addObject:#"Â"]; // 194 0C2
[ascii addObject:#"Ã"]; // 195 0C3
[ascii addObject:#"Ä"]; // 196 0C4
[ascii addObject:#"Å"]; // 197 0C5
[ascii addObject:#"Æ"]; // 198 0C6
[ascii addObject:#"Ç"]; // 199 0C7
[ascii addObject:#"È"]; // 200 0C8
[ascii addObject:#"É"]; // 201 0C9
[ascii addObject:#"Ê"]; // 202 0CA
[ascii addObject:#"Ë"]; // 203 0CB
[ascii addObject:#"Ì"]; // 204 0CC
[ascii addObject:#"Í"]; // 205 0CD
[ascii addObject:#"Î"]; // 206 0CE
[ascii addObject:#"Ï"]; // 207 0CF
// 0D0
[ascii addObject:#"Ð"]; // 208 0D0
[ascii addObject:#"Ñ"]; // 209 0D1
[ascii addObject:#"Ò"]; // 210 0D2
[ascii addObject:#"Ó"]; // 211 0D3
[ascii addObject:#"Ô"]; // 212 0D4
[ascii addObject:#"Õ"]; // 213 0D5
[ascii addObject:#"Ö"]; // 214 0D6
[ascii addObject:#"×"]; // 215 0D7
[ascii addObject:#"Ø"]; // 216 0D8
[ascii addObject:#"Ù"]; // 217 0D9
[ascii addObject:#"Ú"]; // 218 0DA
[ascii addObject:#"Û"]; // 219 0DB
[ascii addObject:#"Ü"]; // 220 0DC
[ascii addObject:#"Ý"]; // 221 0DD
[ascii addObject:#"Þ"]; // 222 0DE
[ascii addObject:#"ß"]; // 223 0DF
// 0E0
[ascii addObject:#"à"]; // 224 0E0
[ascii addObject:#"á"]; // 225 0E1
[ascii addObject:#"â"]; // 226 0E2
[ascii addObject:#"ã"]; // 227 0E3
[ascii addObject:#"ä"]; // 228 0E4
[ascii addObject:#"å"]; // 229 0E5
[ascii addObject:#"æ"]; // 230 0E6
[ascii addObject:#"ç"]; // 231 0E7
[ascii addObject:#"è"]; // 232 0E8
[ascii addObject:#"é"]; // 233 0E9
[ascii addObject:#"ê"]; // 234 0EA
[ascii addObject:#"ë"]; // 235 0EB
[ascii addObject:#"ì"]; // 236 0EC
[ascii addObject:#"í"]; // 237 0ED
[ascii addObject:#"î"]; // 238 0EE
[ascii addObject:#"ï"]; // 239 0EF
// 0F0
[ascii addObject:#"ð"]; // 240 0F0
[ascii addObject:#"ñ"]; // 241 0F1
[ascii addObject:#"ò"]; // 242 0F2
[ascii addObject:#"ó"]; // 243 0F3
[ascii addObject:#"ô"]; // 244 0F4
[ascii addObject:#"õ"]; // 245 0F5
[ascii addObject:#"ö"]; // 246 0F6
[ascii addObject:#"÷"]; // 247 0F7
[ascii addObject:#"ø"]; // 248 0F8
[ascii addObject:#"ù"]; // 249 0F9
[ascii addObject:#"ú"]; // 250 0FA
[ascii addObject:#"û"]; // 251 0FB
[ascii addObject:#"ü"]; // 252 0FC
[ascii addObject:#"ý"]; // 253 0FD
[ascii addObject:#"þ"]; // 254 0FE
[ascii addObject:#"ÿ"]; // 255 0FF
NSInteger i;
for (i=0; i < self.length; i++) {
NSRange range;
range.location = i;
range.length = 1;
NSString *charString = [self substringWithRange:range];
for (NSInteger asciiIdx=0; asciiIdx < ascii.count; asciiIdx++) {
if ([charString isEqualToString:ascii[asciiIdx]]) {
unsigned char c = (unsigned char)asciiIdx;
output[i] = c;
break;
}
}
}
// Don't forget string termination
output[i] = 0;
return (const char*)&output[0];
}
#end